Skip to content

Commit d4bed61

Browse files
committed
[ELF] -r: keep sh_entsize for SHF_MERGE sections with relocations
Follow-up to the NFC refactoring 43e3871 and test cleanup 3cecf17. SHF_MERGE sections with relocations are handled as InputSection (without duplicate elimination). The output section retains the original sh_entsize in non-relocatable links. This patch ports the behavior for relocatable links as well. ClangBuiltLinux/linux#2057
1 parent d6e6478 commit d4bed61

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
904904
// is acceptable because section merging is optional.
905905
if (auto *ms = dyn_cast<MergeInputSection>(s)) {
906906
s = makeThreadLocal<InputSection>(ms->file, ms->name, ms->type,
907-
ms->flags, ms->addralign, 0,
907+
ms->flags, ms->addralign, ms->entsize,
908908
ms->contentMaybeDecompress());
909909
sections[info] = s;
910910
}

lld/test/ELF/merge-reloc.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# CHECK-NEXT: [ 1] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 4
1313
# CHECK-NEXT: [ 2] .rodata.1 PROGBITS 0000000000000000 000040 000004 04 AM 0 0 4
1414
# CHECK-NEXT: [ 3] .rodata.2 PROGBITS 0000000000000000 000048 000008 08 AM 0 0 8
15-
# CHECK-NEXT: [ 4] .rodata.cst8 PROGBITS 0000000000000000 000050 000010 00 AM 0 0 1
15+
# CHECK-NEXT: [ 4] .rodata.cst8 PROGBITS 0000000000000000 000050 000010 08 AM 0 0 1
1616
# CHECK-NEXT: [ 5] .rela.rodata.cst8 RELA 0000000000000000 000068 000030 18 I 9 4 8
17-
# CHECK-NEXT: [ 6] .cst4 PROGBITS 0000000000000000 000060 000008 00 AM 0 0 1
17+
# CHECK-NEXT: [ 6] .cst4 PROGBITS 0000000000000000 000060 000008 04 AM 0 0 1
1818
# CHECK-NEXT: [ 7] .rela.cst4 RELA 0000000000000000 000098 000030 18 I 9 6 8
1919

2020
# OBJDUMP: Contents of section .rodata.1:
@@ -26,7 +26,7 @@
2626
# OBJDUMP: Contents of section .cst4:
2727
# OBJDUMP-NEXT: 0000 00000000 00000000 ........
2828

29-
# CHECK-PDE: [ 2] .cst4 PROGBITS 0000000000200140 000140 000008 00 AM 0 0 1
29+
# CHECK-PDE: [ 2] .cst4 PROGBITS 0000000000200140 000140 000008 04 AM 0 0 1
3030

3131
foo:
3232

0 commit comments

Comments
 (0)