public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110709] New: how to handle the initialization of global struct data for position independent executable application.
@ 2023-07-18  4:09 wangwen at microsoft dot com
  2023-07-18  4:19 ` [Bug target/110709] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: wangwen at microsoft dot com @ 2023-07-18  4:09 UTC (permalink / raw)
  To: 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-18 14:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18  4:09 [Bug c/110709] New: how to handle the initialization of global struct data for position independent executable application wangwen at microsoft dot com
2023-07-18  4:19 ` [Bug target/110709] " pinskia at gcc dot gnu.org
2023-07-18  4:22 ` pinskia at gcc dot gnu.org
2023-07-18  4:39 ` wangwen at microsoft dot com
2023-07-18  5:00 ` pinskia at gcc dot gnu.org
2023-07-18  7:01 ` xry111 at gcc dot gnu.org
2023-07-18 13:30 ` wangwen at microsoft dot com
2023-07-18 14:05 ` xry111 at gcc dot gnu.org
2023-07-18 14:41 ` wangwen at microsoft dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).