Hi all,

I'm having trouble with getting correct section sizes under MinGW.
The example below demonstrates the issue:

test.c:

#include <stdio.h>
#include <stdint.h>

typedef struct
{
    uint16_t a;
    uint16_t b[16];
    uint8_t  c[2];
} test_struct_t;

__attribute__((section("test_section")))
test_struct_t test_struct;

int main(int argc, char** argv) {
        printf("size:%x, sizeof(test_struct_t));
}

After compiling under MinGW [gcc.exe (Rev2, Built by MSYS2 project) 7.1.0] the 
size reported by the program are 0x24 which is correct, however
objdump reports the section size to be 0x40 (which is a problem for my linker 
script)

I did compile the same program under both Clang/Win32 and GCC/Linux and the 
section has correct size of 0x24 in both cases.

Adding align(1) attribute to the data definition is a workaround, that fixes 
the problem, but due to external factors I want to avoid adding it, if possible.
This behavior looks as a bug to me, but I can't say for sure.
Anyhow - is there some other (than the align(1) attribute) approach that this 
behavior can be changed? Compiler option maybe?


Pozdrawiam / Kind Regards
Piotr MadaliƄski
Software Engineer
ZF TRW
Active & Passive Safety Technology
TRW Polska, Czestochowa Engineering Center
ul. Rolnicza 33, 42-200 Czestochowa / Poland
Phone +48 34 343 4864
piotr.madalin...@zf.com<mailto:piotr.madalin...@zf.com>


TRW Polska Sp. z o.o., ul. Rolnicza 33, 42-200 Czestochowa,
Sad Rejonowy w Czestochowie, KRS nr 0000077409
NIP nr 573-010-52-34, kapital zakladowy: 79.581.975 PLN

TRW Polska Sp. z o.o. Rolnicza 33 Str., 42-200 Czestochowa, Poland
District Court for Czestochowa, KRS no. 0000077409,
tax identification no. NIP 573-010-52-34, share capital: 79.581.975 PLN

Niniejsza wiadomosc moze zawierac informacje poufne oraz/lub prawnie chronione, 
przeznaczone do wylacznego uzytku adresata. Jesli nie jestescie Panstwo 
adresatem przesylki lub jesli otrzymaliscie ja Panstwo omylkowo, prosimy o 
bezzwloczne skontaktowanie sie z nadawca i usuniecie tej wiadomosci. Wszelkie 
kopiowanie, wykorzystanie lub rozpowszechnianie tej wiadomosci czy tez 
zawartych w niej informacji przez osoby inne niz adresat jest niedozwolone i 
moze spowodowac odpowiedzialnosc prawna.

This e-mail together with any attachments, may contain confidential and/or 
privileged information. If you are not the intended recipient or have received 
this e-mail in error, please notify the sender immediately and delete this 
e-mail. Any unauthorized copying, disclosure or distribution of the material in 
this e-mail or any attachments is strictly forbidden.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to