Bug 9843 - relocation R_386_GOTOFF against undefined hidden symbol '_begin' can not be used when making a shared object
Summary: relocation R_386_GOTOFF against undefined hidden symbol '_begin' can not be u...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-14 12:38 UTC by Pawel Sikora
Modified: 2014-07-01 20:54 UTC (History)
2 users (show)

See Also:
Host:
Target: i486-gnu-linux
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2009-02-14 12:38:52 UTC
during build glibc-2.8 for i486-gnu-linux target i get following linker error:

(...)
make[3]: Leaving directory
`/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/elf'
i486-gnu-linux-gcc -Wl,--hash-style=both  -nostdlib -nostartfiles -shared
-Wl,-z,now    \
                  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both
-Wl,-z,defs -Wl,--verbose 2>&1 |  \
                  LC_ALL=C \
                  sed -e '/^=========/,/^=========/!d;/^=========/d'    \
                      -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . -
SIZEOF_HEADERS;/' \
                  >
/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/elf/ld.so.lds
i486-gnu-linux-gcc -Wl,--hash-style=both  -nostdlib -nostartfiles -shared -o
/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/elf/ld.so   
                 \
                  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both
-Wl,-z,defs -Wl,-z,now    \
                 
/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/elf/librtld.os -Wl,--version-script=/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/ld.map
           \
                  -Wl,-soname=ld-linux.so.2 -T
/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/elf/ld.so.lds
/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/elf/librtld.os:
In function `_dl_start':
rtld.c:(.text+0x3b8): undefined reference to `_begin'
/local/devel/toolchain43/i486-gnu-linux.host64/lib/gcc/i486-gnu-linux/4.3.3/../../../../i486-gnu-linux/bin/ld:
/home/users/pluto/alatek/toolchain/branches/4.3/glibc-2.8/BUILDDIR/elf/librtld.os:
relocation R_386_GOTOFF against undefined hidden symbol `_begin' can not be used
when making a shared object
/local/devel/toolchain43/i486-gnu-linux.host64/lib/gcc/i486-gnu-linux/4.3.3/../../../../i486-gnu-linux/bin/ld:
final link failed: Bad value
collect2: ld returned 1 exit status


i486-gnu-linux-ld --version
GNU ld (Linux/GNU Binutils) 2.19.51.0.2.20090204


note, that previous version (2.19.51.0.1) works fine.
Comment 1 Andreas Schwab 2009-02-14 14:18:38 UTC
(In reply to comment #0)
>                   sed -e '/^=========/,/^=========/!d;/^=========/d'    \
>                       -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . -
> SIZEOF_HEADERS;/' \

This command is broken and has already been fixed in the glibc repository.
Comment 2 Gary Greene 2009-03-23 01:51:50 UTC
With GLibC 2.9 snapshot 20090316 I still get the same error using binutils 2.19.51.0.2.

Error output below:
make[3]: Leaving directory `/mnt/NEWBR/RPM/BUILD/glibc-2.9/elf'
i586-altimatos-linux-gnu-gcc   -nostdlib -nostartfiles -r -o 
/mnt/NEWBR/RPM/BUILD/build/elf/librtld.os '-Wl,-(' /mnt/NEWBR/RPM/BUILD/build/elf/dl-allobjs.os 
/mnt/NEWBR/RPM/BUILD/build/elf/rtld-libc.a -lgcc '-Wl,-)' \
		  -Wl,-Map,/mnt/NEWBR/RPM/BUILD/build/elf/librtld.os.map
i586-altimatos-linux-gnu-gcc   -nostdlib -nostartfiles -shared 	\
		  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,--verbose 2>&1 |	
\
		  LC_ALL=C \
		  sed -e '/^=========/,/^=========/!d;/^=========/d'	\
		      -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
		  > /mnt/NEWBR/RPM/BUILD/build/elf/ld.so.lds
i586-altimatos-linux-gnu-gcc   -nostdlib -nostartfiles -shared -o 
/mnt/NEWBR/RPM/BUILD/build/elf/ld.so		\
		  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs 	\
		  /mnt/NEWBR/RPM/BUILD/build/elf/librtld.os -Wl,--version-
script=/mnt/NEWBR/RPM/BUILD/build/ld.map		\
		  -Wl,-soname=ld-linux.so.2 -T /mnt/NEWBR/RPM/BUILD/build/elf/ld.so.lds
/mnt/NEWBR/RPM/BUILD/build/elf/librtld.os: In function `_dl_start_final':
/mnt/NEWBR/RPM/BUILD/glibc-2.9/elf/rtld.c:303: undefined reference to `_begin'
/tools/bin/ld: /mnt/NEWBR/RPM/BUILD/build/elf/librtld.os: relocation R_386_GOTOFF against 
undefined hidden symbol `_begin' can not be used when making a shared object
/tools/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [/mnt/NEWBR/RPM/BUILD/build/elf/ld.so] Error 1
make[2]: Leaving directory `/mnt/NEWBR/RPM/BUILD/glibc-2.9/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/mnt/NEWBR/RPM/BUILD/glibc-2.9'
make: *** [all] Error 2
Comment 3 Alan Modra 2009-03-23 04:14:10 UTC
This is not a ld bug, it is a glibc one.  I believe Adreas when he says it has
been fixed, but to be sure I checked the glibc source and indeed it has been fixed.
Comment 4 Gary Greene 2009-03-23 05:19:18 UTC
I'm using the snapshot from the 16th for glibc and I just grabbed binutils 2.19.51.0.3 and I am still 
getting this. Which version of glibc are you claiming that this works on?
Comment 5 Alan Modra 2009-03-23 08:52:15 UTC
Anything with the following patch:

2009-01-29  Andrew Stubbs  <ams@codesourcery.com>

        * elf/Makefile (ld.so): Adjust the sed script to insert _begin in to
        newer linker scripts.

Current mainline CVS of course has it.
Comment 6 Ulrich Drepper 2009-04-07 18:12:01 UTC
I don't know what you test if you see problems.  I'ts long been changed in cvs.