http://sourceware.org/bugzilla/show_bug.cgi?id=13288
Bug #: 13288 Summary: gold silently accepts truncated ELF input Product: binutils Version: 2.23 (HEAD) Status: NEW Severity: normal Priority: P2 Component: gold AssignedTo: i...@airs.com ReportedBy: z...@linux.fjfi.cvut.cz CC: ccout...@google.com Classification: Unclassified Created attachment 5980 --> http://sourceware.org/bugzilla/attachment.cgi?id=5980 Truncated object that ld.gold silently accepts. gold silently accepts truncated input file (tested with ELF64 on amd64). Example of how to reproduce: # compile trivial source file $ echo "int foo(void) { return 42; }" > foo.c $ gcc -c foo.c # create a truncated version of the object # just cutting off one byte creates a broken file, # but gold seems to accept even worse corruption $ stat foo.o | grep Size Size: 1216 Blocks: 8 IO Block: 4096 regular file $ dd if=foo.o of=foo-truncated.o bs=1215 count=1 1+0 records in 1+0 records out 1215 bytes (1.2 kB) copied, 0.000272381 s, 4.5 MB/s # verify that the file is indeed corrupted $ readelf -a foo-truncated.o > /dev/null readelf: Error: Unable to read in 0x18 bytes of relocs $ objdump -r foo-truncated.o foo-truncated.o: file format elf64-x86-64 RELOCATION RECORDS FOR [.eh_frame]:objdump: foo-truncated.o: File truncated # now ask gold to relink it: $ ld.gold -r foo-truncated.o -o relinked.o $ # by the way ld.bfd correctly rejects the file: $ ld.bfd -r foo-truncated.o -o relinked.o foo-truncated.o: could not read symbols: File truncated This can cause difficult-to-track-down issues if an object in larger project is corrupted. (Attaching the exact file I used to reproduce this issue, as the object is compiler dependent and you could possibly get different results with different object.) -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils