This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

ld segfault in binutils-2.12.1 (and later) hppa64-hp-hpux11.00


Hello all,

All the following cases gcc is version 3.1 and all examples work correctly
with HP ld.  There are two seperate (but probably related) problems.
Apologies for being such a long email.

PROBLEM 1 - BUILDING SHARED LIBRARIES WITH UNDEFINED FUNCTION REFERENCES

test1.c
-------
int f1(int a) { return 2*a; }

test2.c
-------
extern int f1(int);
int (*r1)(int) = f1;


ralexand@styx 12:28:05 $more test2.c
ralexand@styx 12:28:07 $gcc -c test1.c
ralexand@styx 12:28:13 $gcc -c test2.c
ralexand@styx 12:28:16 $nm -A test[12].o
test1.o:0000000000000000 T f1
test2.o:                 U f1
test2.o:0000000000000000 D r1

ralexand@styx 12:28:54 $ld -shared -o libtest1.sl test1.o
ralexand@styx 12:29:11 $nm -A libtest1.sl
libtest1.sl:40000000000014e0 T .f1
libtest1.sl:4000000000001120 ? _DYNAMIC
libtest1.sl:8000000000001030 A __bss_start
libtest1.sl:8000000000001030 A _edata
libtest1.sl:8000000000001030 A _end
libtest1.sl:40000000000014e0 T f1

ralexand@styx 12:29:15 $ld -shared -o libtest2.sl test2.o libtest1.sl
Segmentation fault (core dumped)
ralexand@styx 12:30:08 $/usr/ccs/bin/ld -b -o libtst2.sl test2.o libtest1.sl

I have checked it is not a bug with my environment by cross building
binutils-2.12.1 on my i686-linux box and I get the same results.

ralexand@styx 12:52:38 $gdb /opt/dev64/bin/ld
GNU gdb 5.2
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "hppa64-hp-hpux11.00"...
(gdb) run -E -shared -o libtest2.sl test2.o libtest1.sl
Starting program: /opt/dev64/bin/ld -E -shared -o libtest2.sl test2.o libtest1.sl

Program received signal SIGSEGV, Segmentation fault.
0x400000000004654c in elf64_hppa_finalize_opd (dyn_h=0x800000000003d860, 
    data=0x0) at elf64-hppa.c:2135
2135          value = (h->root.u.def.value

(gdb) print h->root.u.def
$1 = {value = 0, section = 0x800000000006cf20}
(gdb) print h->root.u.def.section
$2 = (struct sec *) 0x800000000006cf20
(gdb) print *h->root.u.def.section
$3 = {name = 0x800000000004d7cb ".opd", id = 45, index = 10, 
  next = 0x800000000006d030, flags = 579, user_set_vma = 1, reloc_done = 0, 
  linker_mark = 0, linker_has_input = 0, gc_mark = 0, segment_mark = 0, 
  vma = 9223372036854779920, lma = 9223372036854779920, _cooked_size = 32, 
  _raw_size = 32, output_offset = 0, output_section = 0x0, 
  alignment_power = 3, relocation = 0x0, orelocation = 0x0, reloc_count = 0, 
  filepos = 4112, rel_filepos = 0, line_filepos = 0, userdata = 0x0, 
  contents = 0x0, lineno = 0x0, lineno_count = 0, entsize = 0, comdat = 0x0, 
  moving_line_filepos = 0, target_index = 0, used_by_bfd = 0x8000000000075fb0, 
  constructor_chain = 0x0, owner = 0x800000000004cad0, 
  symbol = 0x8000000000075f50, symbol_ptr_ptr = 0x800000000006cff8, 
  link_order_head = 0x0, link_order_tail = 0x0}


I've looking though some stuff in bfd (elf-hppa64.c and elflink.h) and
some stuff in ld (ldlang.c) but I don't really know where to look
exactly.


PROBLEM 2 - BUILDING EXECUTABLE WITH UNDEFINED FUNCTION REFERENCES

typedef int (*ref)(int);
extern ref r1;

int main()
{
  printf("%d\n", (*r1)(10));
  return 0;
}


ralexand@styx 12:39:50 $nm main.o
0000000000000000 r L$C0000
                 U __main
0000000000000000 T main
                 U printf
                 U r1

ralexand@styx 12:40:37 $cat main.cmd
run -v -E -u main /usr/ccs/lib/pa20_64/crt0.o -L/opt/dev64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1 -L/opt/dev64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1/../../../../hppa64-hp-hpux11.00/lib -L/usr/ccs/bin -L/usr/ccs/lib/pa20_64 -L/opt/langtools/lib/pa20_64 -L/opt/dev64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1/../../.. main.o -lgcc -lc /usr/lib/pa20_64/milli.a -lgcc
ralexand@styx 12:45:02 $gdb /opt/dev64/bin/ld --command=main.cmd
GNU gdb 5.2
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "hppa64-hp-hpux11.00"...
GNU ld version 2.12.1
main.o: In function `main':
main.o(.text+0x28): undefined reference to `r1'

Program received signal SIGSEGV, Segmentation fault.
0x40000000000467a4 in elf64_hppa_finalize_dlt (dyn_h=0x8000000000052b70, 
    data=0x8000000000018e80) at elf64-hppa.c:2267
2267              value = (h->root.u.def.value


Program received signal SIGSEGV, Segmentation fault.
0x40000000000467a4 in elf64_hppa_finalize_dlt (dyn_h=0x8000000000052b70, 
    data=0x8000000000018e80) at elf64-hppa.c:2267
2267              value = (h->root.u.def.value
(gdb) print h->root.u.def
$1 = {value = 9223372036855116120, section = 0x0}


I'm sure the problems are related but it is beyond be as to what the problem
is.  I hope somebody has some good ideas.

Many thanks

Ross Alexander

PS: I'm not on the mailing list so please email me directly.


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