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 target/54226] New: Executables compiled with -pie do not work on NetBSD/sparc or sparc


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

             Bug #: 54226
           Summary: Executables compiled with -pie do not work on
                    NetBSD/sparc or sparc
    Classification: Unclassified
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: martin@netbsd.org


Due to a missing -fPIC when compiling libgcc crtstuff, the binaries are not
actually position independent.

On NetBSD, a "hello world" compiled with gcc -fpie -pie hello.c links to a
binary like this:

a.out:     file format elf64-sparc

Program Header:
    PHDR off    0x0000000000000040 vaddr 0x0000000000000040 paddr
0x0000000000000040 align 2**3
         filesz 0x0000000000000150 memsz 0x0000000000000150 flags r-x
  INTERP off    0x0000000000000190 vaddr 0x0000000000000190 paddr
0x0000000000000190 align 2**0
         filesz 0x0000000000000017 memsz 0x0000000000000017 flags r--
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr
0x0000000000000000 align 2**20
         filesz 0x0000000000000b34 memsz 0x0000000000000b34 flags r-x
...

but of course the first section is not mapped at 0.

Fix is simple: set TARGET_LIBGCC2_CFLAGS in libgcc/config.host (via a new
additional ${tmake_file}) to -fPIC.

I can provide a simple patch doing that, however, I fail to see why this would
be a NetBSD speciality, i.e. why it works without that flags on other systems -
or maybe it just does not work there as well and we need a broader fix (same
solution, different match in config.host).


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