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); }
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
The gABI doesn't support dynamic symbols in more than 64k sections. I am not sure if there is anything we can do.
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.
Fixed with http://sourceware.org/ml/binutils/2006-03/msg00055.html