bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/7023] ld is unable to link 32 bit libffi.so on gcc mainline: Mem


From: ro at TechFak dot Uni-Bielefeld dot DE
Subject: [Bug ld/7023] ld is unable to link 32 bit libffi.so on gcc mainline: Memory exhausted
Date: 11 Nov 2008 22:37:40 -0000

------- Additional Comments From ro at TechFak dot Uni-Bielefeld dot DE  
2008-11-11 22:37 -------
Subject: Re:  New: ld is unable to link 32 bit libffi.so on gcc mainline: 
Memory exhausted

Some additional investigation revealed the following:

* bfd_set_error (bfd_error_no_memory) is called here:

#0  bfd_set_error (error_tag=bfd_error_no_memory) at 
/vol/gnu/src/binutils/binutils-2.19/bfd/bfd.c:425
#1  0x00046e20 in bfd_malloc2 (nmemb=4294967295, size=68719476720) at 
/vol/gnu/src/binutils/binutils-2.19/bfd/libbfd.c:199
#2  0x00064968 in bfd_elf_get_elf_syms (ibfd=0x15c8b0, symtab_hdr=0x0, 
symcount=4294967295, symoffset=1, intsym_buf=0x0, extsym_buf=0x0, 
extshndx_buf=0x0) at /vol/gnu/src/binutils/binutils-2.19/bfd/elf.c:390
#3  0x00078164 in bfd_elf_link_add_symbols (abfd=0x15c8b0, info=0x122920) at 
/vol/gnu/src/binutils/binutils-2.19/bfd/elflink.c:3666
#4  0x00027638 in load_symbols (entry=0x1230b0, place=0xffbff240) at 
/vol/gnu/src/binutils/binutils-2.19/ld/ldlang.c:2573
#5  0x000280dc in open_input_bfds (s=0x1230b0, force=0) at 
/vol/gnu/src/binutils/binutils-2.19/ld/ldlang.c:3002
#6  0x0002dd60 in lang_process () at 
/vol/gnu/src/binutils/binutils-2.19/ld/ldlang.c:6073
#7  0x000306f4 in main (argc=34, argv=0xffbff3d4) at 
/vol/gnu/src/binutils/binutils-2.19/ld/ldmain.c:453

* bfd_elf_get_elf_syms is called with symcount = -1L, which leads to the
  allocation failure observed

* That value of symcount is computed in bfd/elflink.c
  (elf_link_add_object_symbols): at line 3674 (current binutils mainline)

  symcount =0, hdr->sh_info = 1 -> extsymcount = -1LL

  hdr is like this at this point:

(gdb) p hdr
$6 = (Elf_Internal_Shdr *) 0x213d00
(gdb) p *$6
$7 = {sh_name = 11, sh_type = 2, sh_flags = 2, sh_addr = 0, sh_offset = 88, 
sh_size = 0, sh_link = 3, sh_info = 1, sh_addralign = 1, sh_entsize = 16, 
bfd_section = 0x0, contents = 0x0}

  further investigation with readelf gives:

% readelf -S src/sparc/.libs/v9.o 
There are 5 section headers, starting at offset 0x94:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .shstrtab         STRTAB          00000000 000034 000024 00      0   0  1
  [ 2] .symtab           SYMTAB          00000000 000058 000000 10   A  3   1  1
  [ 3] .strtab           STRTAB          00000000 000058 000001 00   A  0   0  1
  [ 4] .comment          PROGBITS        00000000 000059 00003b 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

I'm not sure how best to fix this: the following hack worked for me:

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.315
diff -u -p -r1.315 elflink.c
--- bfd/elflink.c       20 Oct 2008 10:57:33 -0000      1.315
+++ bfd/elflink.c       11 Nov 2008 22:32:25 -0000
@@ -3671,7 +3671,10 @@ elf_link_add_object_symbols (bfd *abfd, 
     }
   else
     {
-      extsymcount = symcount - hdr->sh_info;
+      if (symcount > 0)
+       extsymcount = symcount - hdr->sh_info;
+      else
+       extsymcount = symcount;
       extsymoff = hdr->sh_info;
     }
 


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=7023

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

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