https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110709
Bug ID: 110709 Summary: how to handle the initialization of global struct data for position independent executable application. Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: wangwen at microsoft dot com Target Milestone: --- our project is to dynamically load applications in azure-rtos. the application is compiled with "-O0 -ffunction-sections -Wall -fno-plt -fpie -msingle-pic-base -mno-pic-data-is-text-relative -fPIC" when there are global variables defined in below ways, the initialized value of struct members can't be loaded correctly. " typedef struct { char testChArray[100]; int test_A; const char *text; int test_B; }GCC_TEST_t; GCC_TEST_t user_test = {"struct member testChArray",10,"const char *text",27}; " if the pointer member "text" is initialized when "user_test" is declared. the "user_test" will be placed at section ".data.rel.local"; but other members like "testChArray" would be initialized with relocated value which would be wrong, So we wonder if PIC supports such struct data initialization that struct data is composed with array and pointer and initialized when declared.