Hello list,
I'm a developer at 0xlab and focus on toolchain development.
While Android WG was working on integrating Linaro toolchain to Android system, we encountered prelink error since there are some empty symbols in symtab produced by toolchain linaro gcc-4.5 + binutils-2.20. The error message is:
target Prelink: libc (out/target/product/beagleboard/symbols/system/lib/libc.so) ASSERTION FAILURE external/elfcopy/elfcopy.c:2457: [!(shdr_info[sym->st_shndx].shdr.sh_flags & SHF_ALLOC)]
However, we verified it by linaro gcc-4.5 + google binutils-2.19. There is no prelink problem on this toolchain combination. (Google binutils-2.19 is not compatible to linaro gcc-4.5 since some new feature and new instructions used in linaro gcc-4.5).
We produced the link map file and traced this problem, the symbols are merged by linker optimization (relax) and empty entires are inserted in symtab. In function elf_link_output_sym at bfd/elflink.c:
if (name == NULL || *name == '\0') elfsym->st_name = 0; else if (input_sec->flags & SEC_EXCLUDE) elfsym->st_name = 0; // st_name will be set to emtry else { elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab, name, TRUE, FALSE); if (elfsym->st_name == (unsigned long) -1) return 0; }
When const strings are merged, the bit of SEC_EXCLUDE in input_sec->flags will be set. The bfd elf linker will set the elfsym->st_name to 0. Before binutils-2.19, the merged string is pushed in section 'glue_t' and the path is not be traveled.
I think it's not make sense that the address of NOTYPE symbol *not* behind its section. The zero must be not behind section "rodata.str1.1". So I filed a bug in https://bugs.launchpad.net/binutils-linaro/+bug/707487https://bugs.launchpad.net/binutils-linaro/+bug/707487/+subscribe .
The log is readelf -a libc.so | grep 00000000 | grep -v FILE | grep -v SECTION | grep -v UND 3372: 00000000 0 NOTYPE LOCAL DEFAULT 8 3375: 00000000 0 NOTYPE LOCAL DEFAULT 8 3381: 00000000 0 NOTYPE LOCAL DEFAULT 8 3382: 00000000 0 NOTYPE LOCAL DEFAULT 8 3397: 00000000 0 NOTYPE LOCAL DEFAULT 8 3408: 00000000 0 NOTYPE LOCAL DEFAULT 8 3409: 00000000 0 NOTYPE LOCAL DEFAULT 8 3411: 00000000 0 NOTYPE LOCAL DEFAULT 8 3415: 00000000 0 NOTYPE LOCAL DEFAULT 8 3424: 00000000 0 NOTYPE LOCAL DEFAULT 8 3437: 00000000 0 NOTYPE LOCAL DEFAULT 8 3439: 00000000 0 NOTYPE LOCAL DEFAULT 8
Any comments?
Thanks, Luse http://0xlab.org/
2011/1/26 Meng-Hsuan Cheng luse@0xlab.org:
While Android WG was working on integrating Linaro toolchain to Android system, we encountered prelink error since there are some empty symbols in symtab produced by toolchain linaro gcc-4.5 + binutils-2.20.
[...]
So I filed a bug in https://bugs.launchpad.net/binutils-linaro/+bug/707487.
[...]
hi luse,
Thanks for reporting. To clarify, I just make list about the combination and test results.
Original: csl-gcc + csl-binutils (binutils-2.20.51) => FAIL
Once the version of linaro-gcc is set to gcc-linaro-4.5-2011.01-1, binutils tests: linaro-gcc + binutils-2.19 (FSF) => OK linaro-gcc + binutils-2.20.1 (FSF) => OK linaro-gcc + binutils-2.21 (FSF) => FAIL linaro-gcc + binutils-2.20.51 (CSL) => FAIL linaro-gcc + binutils-2.20.1 (Google) => OK
Source: (1) FSF: upstream (2) CSL: CodeSourcery 2010q3 (3) Google: http://android.git.kernel.org/?p=toolchain/binutils.git%3Ba=summary
Since binutils is not yet maintained by Linaro directly, Android WG would just take binutils 2.20.1 from Google.
Sincerely, Jim Huang (jserv) http://0xlab.org/