This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/37506] New: attribute section is not working with constant strings


With the __attribute__ __section__ it is possible to allocate variables to
different section than the default (
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html ). In case of the
following source code I would achieve to allocate both "foo bar" and "Hello
World!" strings into the .xxx_section section:

char x[] __attribute__ ((__section__(".xxx_section"))) = "foo bar";
char* y __attribute__ ((__section__(".xxx_section"))) = "Hello World!";

int main() {
        return 0;
}

However, with gcc version 4.3.1 (Debian 4.3.1-9) only the "foo bar" string is
stored in .xxx_section:

$ objdump -s a.out

a.out:     file format elf32-i386
[...]
Contents of section .rodata:
 8048448 03000000 01000200 48656c6c 6f20576f  ........Hello Wo
 8048458 726c6421 00                          rld!.           
[...]
Contents of section .xxx_section:
 8049568 666f6f20 62617200 50840408           foo bar.P...


-- 
           Summary: attribute section is not working with constant strings
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nm127 at freemail dot hu
 GCC build triplet: 4.3.1
GCC target triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37506


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]