[Bug target/110709] how to handle the initialization of global struct data for position independent executable application.

2023-07-18 Thread wangwen at microsoft dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110709

--- Comment #8 from wangwen at microsoft dot com ---
I posted it in the wrong place, please just delete it.
thank you.

[Bug target/110709] how to handle the initialization of global struct data for position independent executable application.

2023-07-18 Thread wangwen at microsoft dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110709

--- Comment #6 from wangwen at microsoft dot com ---
would anyone guide me any place to ask such question?

[Bug target/110709] how to handle the initialization of global struct data for position independent executable application.

2023-07-17 Thread wangwen at microsoft dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110709

--- Comment #3 from wangwen at microsoft dot com ---
when the global pointer variety has an initialized value which is not NULL,
then the value should be an address, so the initialized value should be
recalculated when dynamically loaded.

Now the problem is the array member and pointer member of struct data will be
place at same section, then the loader would not know how to calculate the
initialized value, because it has no idea the value is an address or is normal
data.

it is a long story if you are interested in how the problem is brought up.
I pasted the link where we are trying to solve it.
https://github.com/azure-rtos/threadx/issues/230

[Bug c/110709] New: how to handle the initialization of global struct data for position independent executable application.

2023-07-17 Thread wangwen at microsoft dot com via Gcc-bugs
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.