Remove an unnecessary constraint.

Our current implementation of SHF_MERGE can already handle over
aligned elements.

llvm-svn: 318310
This commit is contained in:
Rafael Espindola 2017-11-15 17:31:27 +00:00
parent 8237141be1
commit 3f0b575363
2 changed files with 35 additions and 10 deletions

View File

@ -319,16 +319,7 @@ template <class ELFT> bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &Sec) {
if (Flags & SHF_WRITE)
fatal(toString(this) + ": writable SHF_MERGE section is not supported");
// Don't try to merge if the alignment is larger than the sh_entsize and this
// is not SHF_STRINGS.
//
// Since this is not a SHF_STRINGS, we would need to pad after every entity.
// It would be equivalent for the producer of the .o to just set a larger
// sh_entsize.
if (Flags & SHF_STRINGS)
return true;
return Sec.sh_addralign <= EntSize;
return true;
}
template <class ELFT>

View File

@ -0,0 +1,34 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: ld.lld %t.o -o %t.so -shared
// RUN: llvm-readobj -s -section-data %t.so | FileCheck %s
.section .rodata.foo,"aM",@progbits,1
.align 16
.byte 0x42
.section .rodata.bar,"aM",@progbits,1
.align 16
.byte 0x42
.section .rodata.zed,"aM",@progbits,1
.align 16
.byte 0x41
// CHECK: Name: .rodata (
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_MERGE
// CHECK-NEXT: ]
// CHECK-NEXT: Address:
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 17
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 16
// CHECK-NEXT: EntrySize: 1
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 42000000 00000000 00000000 00000000 |
// CHECK-NEXT: 0010: 41 |
// CHECK-NEXT: )