[PATCH] D23713: [ELF] - Fix for PR26968 - i386 lld produces incorrect fatal error "SHF_MERGE section size must be a multiple of sh_entsize"
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 05:58:12 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Herald added a subscriber: emaste.
Accordind to PR26968 description,
"In a FreeBSD/i386 buildworld many objects have SHF_MERGE with sh_entsize == 0, and this shouldn't be a fatal error. "
Probably we do not want to spread the fix on different targets as looks these objects are just broken on i386.
So patch fixes it only for I386 target.
https://reviews.llvm.org/D23713
Files:
ELF/InputFiles.cpp
test/ELF/Inputs/invalid-shentsize-zero-i386.elf
test/ELF/invalid-elf.test
Index: test/ELF/invalid-elf.test
===================================================================
--- test/ELF/invalid-elf.test
+++ test/ELF/invalid-elf.test
@@ -28,6 +28,10 @@
# RUN: FileCheck --check-prefix=INVALID-SHENTSIZE-ZERO %s
# INVALID-SHENTSIZE-ZERO: SHF_MERGE section size must be a multiple of sh_entsize
+## In a FreeBSD/i386 world many objects have SHF_MERGE with sh_entsize == 0.
+# RUN: ld.lld %p/Inputs/invalid-shentsize-zero-i386.elf -o %t2
+# RUN: llvm-readobj %t2 > /dev/null
+
# RUN: not ld.lld %p/Inputs/invalid-multiple-eh-relocs.elf -o %t2 2>&1 | \
# RUN: FileCheck --check-prefix=INVALID-EH-RELOCS %s
# INVALID-EH-RELOCS: multiple relocation sections to .eh_frame are not supported
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -184,6 +184,10 @@
if (Flags & SHF_WRITE)
fatal(getFilename(this) + ": writable SHF_MERGE section is not supported");
uintX_t EntSize = Sec.sh_entsize;
+
+ // In a FreeBSD/i386 world many objects have SHF_MERGE with sh_entsize == 0.
+ if (!EntSize && Config->EMachine == EM_386)
+ return false;
if (!EntSize || Sec.sh_size % EntSize)
fatal(getFilename(this) +
": SHF_MERGE section size must be a multiple of sh_entsize");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23713.68678.patch
Type: text/x-patch
Size: 1320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160819/7d083cb3/attachment.bin>
More information about the llvm-commits
mailing list