[...@gnu-6 pr11939]$ cat x.s [...@gnu-6 pr11939]$ as -o x.o x.s [...@gnu-6 pr11939]$ valgrind --tool=memcheck ld x.o -b binary binary ==23971== Memcheck, a memory error detector ==23971== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==23971== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info ==23971== Command: ld x.o -b binary binary ==23971== ==23971== Conditional jump or move depends on uninitialised value(s) ==23971== at 0x41C174: gldelf_x86_64_before_allocation (eelf_x86_64.c:1342) ==23971== by 0x411CF8: lang_process (ldlang.c:6395) ==23971== by 0x4152B9: main (ldmain.c:524) ==23971== ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078 ==23971== ==23971== HEAP SUMMARY: ==23971== in use at exit: 168,517 bytes in 610 blocks ==23971== total heap usage: 657 allocs, 47 frees, 294,775 bytes allocated ==23971== ==23971== LEAK SUMMARY: ==23971== definitely lost: 10,907 bytes in 100 blocks ==23971== indirectly lost: 0 bytes in 0 blocks ==23971== possibly lost: 15,079 bytes in 263 blocks ==23971== still reachable: 142,531 bytes in 247 blocks ==23971== suppressed: 0 bytes in 0 blocks ==23971== Rerun with --leak-check=full to see details of leaked memory ==23971== ==23971== For counts of detected and suppressed errors, rerun with: -v ==23971== Use --track-origins=yes to see where uninitialised values come from ==23971== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 6 from 6)
The problem is in gld${EMULATION_NAME}_before_allocation: for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next) { const char *audit_libs = elf_dt_audit (abfd); We should check if input is ELF first. -- Summary: Invalid memory access in ELF before_allocation Product: binutils Version: 2.21 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: hjl dot tools at gmail dot com CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=11946 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils