On Tue, 22 Aug 2017, Szabolcs Nagy wrote: > On 22/08/17 11:17, Richard Biener wrote: > > On Tue, 22 Aug 2017, Szabolcs Nagy wrote: > >> on aarch64_be-none-elf i see > >> > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 (test for excess errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O (test for excess errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -O3 (test for excess errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 (test for excess errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O (test for excess > >> errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g1 -O3 (test for excess > >> errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 (test for excess errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O (test for excess > >> errors) > >> PASS->FAIL: gcc.dg/debug/pr41893-1.c -gdwarf-2 -g3 -O3 (test for excess > >> errors) > >> PASS->FAIL: gcc.dg/lto/20090914-1 > >> c_lto_20090914-1_0.o-c_lto_20090914-1_0.o link, -flto > >> PASS->FAIL: gcc.dg/lto/20100426 c_lto_20100426_0.o-c_lto_20100426_0.o > >> link, -r -nostdlib -flto -g > >> PASS->FAIL: gcc.dg/lto/20111207-2 > >> c_lto_20111207-2_0.o-c_lto_20111207-2_0.o link, -g -O -flto > >> PASS->FAIL: gcc.dg/lto/20111213-1 > >> c_lto_20111213-1_0.o-c_lto_20111213-1_0.o link, -flto -g > >> PASS->FAIL: gcc.dg/lto/pr51572-1 c_lto_pr51572-1_0.o-c_lto_pr51572-1_0.o > >> link, -flto -g > >> PASS->FAIL: gcc.dg/lto/pr53470 c_lto_pr53470_0.o-c_lto_pr53470_0.o link, > >> -flto -g > >> PASS->FAIL: gcc.dg/lto/pr59323 c_lto_pr59323_0.o-c_lto_pr59323_0.o link, > >> -O2 -g -flto > >> PASS->FAIL: gcc.dg/lto/pr59323-2 c_lto_pr59323-2_0.o-c_lto_pr59323-2_0.o > >> link, -O2 -g -flto > >> PASS->FAIL: gcc.dg/pr43557-1.c (test for excess errors) > >> > >> linking seems to fail with > >> > >> /tmp/ccqAb1Wfdebugobjtem: file not recognized: Bad value > >> collect2: error: ld returned 1 exit status > >> lto-wrapper: fatal error: B/gcc/xgcc returned 1 exit status > >> compilation terminated. > >> P/aarch64_be-none-elf/bin/ld: error: lto-wrapper failed > >> collect2: error: ld returned 1 exit status > >> compiler exited with status 1 > > > > Can you file a bugreport please? Can you investigate a bit, I suspect > > a simple int main() {} and ./xgcc -B. -flto -g t.c fails the same way. > > With -save-temps -v you should be able to inspect the generated > > debugobj with readelf. > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81925 > > i could not figure much out, readelf could parse lto1 input > but printed errors on the final link command input. > > > Is this a native compiler or a cross-compiler? [I suspect endianess > > issues somewhere?] > > cross compiler (from aarch64-linux-gnu to aarch64_be-none-elf)
I am testing the following fix (verified with a cross), will apply as obvious if that succeeds. Richard. 2017-08-22 Richard Biener <rguent...@suse.de> PR lto/81925 * simple-object-elf.c (simple_object_elf_write_shdr): Adjust type of sh_addralign and sh_entsize and properly write sh_entsize as Elf_Addr. (simple_object_elf_write_to_file): Read sh_entsize as Elf_Addr. Index: libiberty/simple-object-elf.c =================================================================== --- libiberty/simple-object-elf.c (revision 251273) +++ libiberty/simple-object-elf.c (working copy) @@ -830,8 +830,8 @@ simple_object_elf_write_shdr (simple_obj off_t sh_addr, unsigned int sh_offset, unsigned int sh_size, unsigned int sh_link, unsigned int sh_info, - unsigned int sh_addralign, - unsigned int sh_entsize, + size_t sh_addralign, + size_t sh_entsize, const char **errmsg, int *err) { struct simple_object_elf_attributes *attrs = @@ -858,7 +858,7 @@ simple_object_elf_write_shdr (simple_obj ELF_SET_FIELD (fns, cl, Shdr, buf, sh_link, Elf_Word, sh_link); ELF_SET_FIELD (fns, cl, Shdr, buf, sh_info, Elf_Word, sh_info); ELF_SET_FIELD (fns, cl, Shdr, buf, sh_addralign, Elf_Addr, sh_addralign); - ELF_SET_FIELD (fns, cl, Shdr, buf, sh_entsize, Elf_Word, sh_entsize); + ELF_SET_FIELD (fns, cl, Shdr, buf, sh_entsize, Elf_Addr, sh_entsize); return simple_object_internal_write (descriptor, offset, buf, shdr_size, errmsg, err); @@ -948,8 +948,8 @@ simple_object_elf_write_to_file (simple_ off_t sh_addr = 0; unsigned int sh_link = 0; unsigned int sh_info = 0; - unsigned int sh_addralign = 1U << section->align; - unsigned int sh_entsize = 0; + size_t sh_addralign = 1U << section->align; + size_t sh_entsize = 0; if (eow->shdrs) { sh_type = ELF_FETCH_FIELD (attrs->type_functions, attrs->ei_class, Shdr, @@ -972,7 +972,7 @@ simple_object_elf_write_to_file (simple_ sh_addralign, Elf_Addr); sh_entsize = ELF_FETCH_FIELD (attrs->type_functions, attrs->ei_class, Shdr, eow->shdrs + secnum * shdr_size, - sh_entsize, Elf_Word); + sh_entsize, Elf_Addr); secnum++; }