Issue Details (XML | Word | Printable)

Key: PCC-145
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

-fPIC may generate incorrect section headers for data

Created: 04/Jun/10 09:33 PM   Updated: 09/Jun/10 03:59 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
building libraries in NetBSD with HAVE_PCC= often produces the following error, caused by -fPIC in the arguments.

  i486--netbsdelf-ld: warning: creating a DT_TEXTREL in a shared object.

I think that this is produced because some data is placed in the wrong section, and the use of --warn-shared-textrel in the arguments.

The following code illustrates the issue

  char *foo[] = {

when compiled with "gcc -S" (before) and "gcc -S -fPIC" (after) the following change was observed

        .file "rel.c"
 .globl foo
        .section .rodata
        .string "aaaa"
- .data
+ .section .data.rel.local,"aw",@progbits
        .align 4
        .type foo, @object
        .size foo, 4
        .long .LC0
        .ident "GCC: (GNU) 4.1.3 20080704 prerelease (NetBSD nb2 20081120)"

whereas with "pcc -S" and "pcc -S -fPIC" there was no difference:

        .section .rodata
        .ascii "aaaa\0"
        .align 4
        .globl foo
        .type foo,@object
        .long 0+.L11
        .ident "PCC: pcc 0.9.9 [20100604] (netbsd)"

I don't actually have any reference to what should happen with data compiled with -fPIC, but GNU ld 2.19.1 clearly thinks there may be a problem..

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 09/Jun/10 01:01 PM
Hm, initialized objects containing pointers must be put in .data.rel.local,"aw",@progbits otherwise the pointer data won't be relocated.

Anders Magnusson added a comment - 09/Jun/10 03:59 PM
So, done. Please check that it works for you too.