Bug 2379 - pie.exp: FAIL: weak undefined
Summary: pie.exp: FAIL: weak undefined
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 00:10 UTC by John David Anglin
Modified: 2006-03-20 04:25 UTC (History)
3 users (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2006-02-22 00:10:27 UTC
gcc  -B/home/dave/gnu/binutils-2.16.91/objdir/ld/tmpdir/gas/ -I/home/dave/gnu/bi
nutils-2.16.91/src/ld/testsuite/ld-pie -g -O0   -L/home/dave/gnu/binutils-2.16.9
1/objdir/./ld -c -g -O0 -fPIC -c /home/dave/gnu/binutils-2.16.91/src/ld/testsuit
e/ld-pie/weakundef.c -o tmpdir/weakundef.o
gcc -L/home/dave/gnu/binutils-2.16.91/objdir/./ld -B/home/dave/gnu/binutils-2.16
.91/objdir/ld/tmpdir/ld/ -L/home/dave/opt/gnu/hppa-linux/lib -L/home/dave/opt/gn
u/lib -L/usr/local/lib -L/lib -L/usr/lib  -o tmpdir/weakundef -L/home/dave/gnu/b
inutils-2.16.91/src/ld/testsuite/ld-pie -pie tmpdir/weakundef.o
Running: tmpdir/weakundef > tmpdir/weakundef.out
tmpdir/weakundef: error while loading shared libraries: unexpected reloc type 0x
42
FAIL: weak undefined

Also,

gcc  -B/home/dave/gnu/binutils-2.16.91/objdir/ld/tmpdir/gas/ -I/home/dave/gnu/bi
nutils-2.16.91/src/ld/testsuite/ld-pie -g -O0   -L/home/dave/gnu/binutils-2.16.9
1/objdir/./ld -c -g -O0 -fPIC -c /home/dave/gnu/binutils-2.16.91/src/ld/testsuit
e/ld-pie/weakundef-data.c -o tmpdir/weakundef-data.o
gcc -L/home/dave/gnu/binutils-2.16.91/objdir/./ld -B/home/dave/gnu/binutils-2.16
.91/objdir/ld/tmpdir/ld/ -L/home/dave/opt/gnu/hppa-linux/lib -L/home/dave/opt/gn
u/lib -L/usr/local/lib -L/lib -L/usr/lib  -o tmpdir/weakundef-data -L/home/dave/
gnu/binutils-2.16.91/src/ld/testsuite/ld-pie -pie tmpdir/weakundef-data.o
Running: tmpdir/weakundef-data > tmpdir/weakundef-data.out
tmpdir/weakundef-data: error while loading shared libraries: unexpected reloc ty
pe 0x42
FAIL: weak undefined data
Comment 1 dave@hiauly1.hia.nrc.ca 2006-02-22 01:10:47 UTC
Subject: Re:  New: pie.exp: FAIL: weak undefined

> tmpdir/weakundef: error while loading shared libraries: unexpected reloc type 0x
> 42

This is R_PARISC_PLABEL21L.

Dave
Comment 2 dave@hiauly1.hia.nrc.ca 2006-02-24 18:55:53 UTC
Subject: Re:  New: pie.exp: FAIL: weak undefined

> > tmpdir/weakundef: error while loading shared libraries: unexpected reloc type 0x
> > 42
> 
> This is R_PARISC_PLABEL21L.

This is a glibc bug.  The dynamic loader doesn't yet support
R_PARISC_PLABEL21L and R_PARISC_PLABEL14R, and the startup file
/usr/lib/Scrt1.o introduces them into the executable when -pie
is specified:

/usr/lib/Scrt1.o:     file format elf32-hppa-linux

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000000 R_PARISC_PLABEL21L  main
00000004 R_PARISC_PLABEL14R  main
00000010 R_PARISC_PLABEL21L  __libc_csu_init
00000014 R_PARISC_PLABEL14R  __libc_csu_init
00000018 R_PARISC_PLABEL21L  __libc_csu_fini
0000001c R_PARISC_PLABEL14R  __libc_csu_fini

Dave
Comment 3 H.J. Lu 2006-03-01 01:26:59 UTC
See

http://sourceware.org/ml/binutils/2006-02/msg00278.html

hppa may need a similar fix.
Comment 4 dave@hiauly1.hia.nrc.ca 2006-03-20 02:20:00 UTC
Subject: Re:  pie.exp: FAIL: weak undefined

> See
> 
> http://sourceware.org/ml/binutils/2006-02/msg00278.html
> 
> hppa may need a similar fix.

You mean something like:

Index: elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.144
diff -u -3 -p -r1.144 elf32-hppa.c
--- elf32-hppa.c	16 Mar 2006 12:20:15 -0000	1.144
+++ elf32-hppa.c	20 Mar 2006 02:04:22 -0000
@@ -4261,6 +4261,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte
 #define elf_backend_fake_sections	     elf_hppa_fake_sections
 #define elf_backend_relocate_section	     elf32_hppa_relocate_section
 #define elf_backend_hide_symbol		     elf32_hppa_hide_symbol
+#define elf_backend_fixup_symbol	     _bfd_elf_link_hash_fixup_symbol
 #define elf_backend_finish_dynamic_symbol    elf32_hppa_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections  elf32_hppa_finish_dynamic_sections
 #define elf_backend_size_dynamic_sections    elf32_hppa_size_dynamic_sections

This doesn't work.

Possibly, I don't understand but the testsuite fails don't appear to
have anything to do with undefined weak symbols:

dave@gsyprf11:~/binutils-2.16.91/objdir$ nm /usr/lib/Scrt1.o|less
         U $global$
00000000 R _IO_stdin_used
00000000 D __data_start
	 U __libc_csu_fini
	 U __libc_csu_init
	 U __libc_start_main
00000000 T _start
00000000 W data_start
	 U main

The problem is main, __libc_csu_init and __libc_csu_fini are in
a shared library, and the dynamic loader can't do the necessary
fixups.

Dave
Comment 5 H.J. Lu 2006-03-20 04:05:31 UTC
Does PIE work on hppa at all?
Comment 6 dave@hiauly1.hia.nrc.ca 2006-03-20 04:23:32 UTC
Subject: Re:  pie.exp: FAIL: weak undefined

> Does PIE work on hppa at all?

My understanding is that it does when the dynamic loader issue
is fixed in libc6 2.3.6-1.  It seems 2.3.6 was released today
(I just did an apt-get update and upgrade a few minutes ago) and
tests no longer fail.  This PR can now be closed.

Dave
Comment 7 John David Anglin 2006-03-20 04:25:08 UTC
Fixed by updating to glibc 2.3.6-3.