bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/19805] New: visibility=hidden and .a fails


From: felix-glibc at fefe dot de
Subject: [Bug ld/19805] New: visibility=hidden and .a fails
Date: Thu, 10 Mar 2016 12:17:47 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=19805

            Bug ID: 19805
           Summary: visibility=hidden and .a fails
           Product: binutils
           Version: 2.26
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: felix-glibc at fefe dot de
  Target Milestone: ---

Problem 1:

/usr/bin/ld:
/hdd/home/leitner/projects/dietlibc-0.32/bin-x86_64/dietlibc.a(perror.o):
relocation R_X86_64_PC32 against symbol `sys_errlist' can not be used when
making a shared object; recompile with -fPIC

This code was already compiled with -fPIC. You can actually tell from the
relocation, it is PC-relative, i.e. position independent.

$ nm bin-x86_64/dietlibc.a | grep sys_errlist
0000000000000000 R sys_errlist
                 U sys_errlist
                 U sys_errlist

so the symbol is being exported, and somebody else is using it with a PIC
reference. ld should not be refusing to do this.

Note that I compiled all the code with -fvisibility=hidden, and I am also
passing that flag to gcc when creating the "shared library" PIE binary here, to
make sure the reference is resolved internally.

I know that gcc is telling ld about the visibility, because calls are doing
directly (as opposed to through the PLT).

Problem 2: .a vs loose object files:

$ gcc -nostdlib -shared -L/opt/diet/lib-x86_64 /opt/diet/lib-x86_64/start-pie.o
-fpie -fvisibility=hidden -o y c.o d.o -isystem /opt/diet/include
-D__dietlibc__ /opt/diet/lib-x86_64/libc.a -lgcc

-> works, produces a working binary.

$ ar cru x.a c.o d.o
$ gcc -nostdlib -shared -L/opt/diet/lib-x86_64 /opt/diet/lib-x86_64/start-pie.o
-fpie -fvisibility=hidden -o y x.a -isystem /opt/diet/include -D__dietlibc__
/opt/diet/lib-x86_64/libc.a -lgcc
/opt/diet/lib-x86_64/libc.a(stackgap-pie.o): In function `stackgap_pie':
stackgap-pie.c:(.text+0x39b): undefined reference to `main'
/usr/bin/ld: y: hidden symbol `main' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
$ nm x.a
[...]
d.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U __you_tried_to_link_a_dietlibc_object_against_glibc
                 U foo
0000000000000000 T main
                 U puts

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]