Bug 2411 - ELF linker fails to create executable with more than 64k sections
Summary: ELF linker fails to create executable with more than 64k sections
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-02 20:39 UTC by H.J. Lu
Modified: 2006-04-05 18:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A testcase (25.71 KB, application/octet-stream)
2006-03-02 20:40 UTC, H.J. Lu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2006-03-02 20:39:08 UTC
ELF linker has lines like

bed->s->swap_symbol_out (abfd, &sym, dest, 0);

It doesn't work when creating DSO with 64k sections due to

elf_swap_symbol_out (bfd *abfd,
                     const Elf_Internal_Sym *src,
                     void *cdst,
                     void *shndx)
{
  unsigned int tmp;
  Elf_External_Sym *dst = cdst;
  H_PUT_32 (abfd, src->st_name, dst->st_name);
  H_PUT_WORD (abfd, src->st_value, dst->st_value);
  H_PUT_WORD (abfd, src->st_size, dst->st_size);
  H_PUT_8 (abfd, src->st_info, dst->st_info);
  H_PUT_8 (abfd, src->st_other, dst->st_other);
  tmp = src->st_shndx;
  if (tmp > SHN_HIRESERVE)
    {
      if (shndx == NULL)
        abort ();
      H_PUT_32 (abfd, tmp, shndx);
      tmp = SHN_XINDEX;
    }
  H_PUT_16 (abfd, tmp, dst->st_shndx);
}
Comment 1 H.J. Lu 2006-03-02 20:40:03 UTC
Created attachment 898 [details]
A testcase

gcc -fPIC   -c -o sect.o sect.c
gcc -shared -o libsect.so sect.o
/usr/local/bin/ld: BFD 2.16.91.0.7 20060228 internal error, aborting at
/net/gnu-13/export/linux/src/binutils/binutils/bfd/elfcode.h line 215 in
bfd_elf64_swap_symbol_out

/usr/local/bin/ld: Please report this bug.

collect2: ld returned 1 exit status
Comment 2 H.J. Lu 2006-03-02 22:08:00 UTC
The gABI doesn't support dynamic symbols in more than 64k sections. I am
not sure if there is anything we can do.
Comment 3 H.J. Lu 2006-03-02 22:48:55 UTC
I guess the 64k section support is incomplete. If there are more than 64k
sections, entries in the dynamic symbol table may reference sections beyond
64k:

gcc -B./ -o bar sect.o bar.o
/usr/local/bin/ld: BFD 2.16.91.0.7 20060228 internal error, aborting at
/net/gnu-13/export/linux/src/binutils/binutils/bfd/elfcode.h line 215 in
bfd_elf64_swap_symbol_out

/usr/local/bin/ld: Please report this bug.

collect2: ld returned 1 exit status

I guess linker should stop well before getting abort.
Comment 4 H.J. Lu 2006-04-05 18:15:14 UTC
Fixed with

http://sourceware.org/ml/binutils/2006-03/msg00055.html