[PATCH] D38846: [ELF] - Linkerscript: fix issue with SUBALIGN.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 06:45:26 PDT 2017
grimar updated this revision to Diff 119312.
grimar retitled this revision from "[ELF] - Linkerscript: Fix issues with SUBALIGN." to "[ELF] - Linkerscript: fix issue with SUBALIGN.".
grimar edited the summary of this revision.
https://reviews.llvm.org/D38846
Files:
ELF/LinkerScript.cpp
test/ELF/linkerscript/subalign.s
Index: test/ELF/linkerscript/subalign.s
===================================================================
--- test/ELF/linkerscript/subalign.s
+++ test/ELF/linkerscript/subalign.s
@@ -22,6 +22,17 @@
# SUBALIGN: 01000000 00000000 02000000 00000000
# SUBALIGN: 03000000 00000000 04000000 00000000
+## Test we do not fail when dot(.) is used inside SUBALIGN. That is not
+## consistent with ld.bfd.
+# RUN: echo "SECTIONS { . = 0x32; .aaa : SUBALIGN(.) { *(.aaa*) } }" > %t3.script
+# RUN: ld.lld %t1.o --script %t3.script -o %t3
+# RUN: llvm-objdump -s %t3 | FileCheck -check-prefix=SUBALIGN %s
+
+## Test we are able to link with zero alignment, this is consistent with bfd 2.26.1.
+# RUN: echo "SECTIONS { .aaa : SUBALIGN(0) { *(.aaa*) } }" > %t4.script
+# RUN: ld.lld %t1.o --script %t4.script -o %t4
+# RUN: llvm-objdump -s %t4 | FileCheck -check-prefix=SUBALIGN %s
+
.global _start
_start:
nop
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -402,7 +402,8 @@
// is given, input sections are aligned to that value, whether the
// given value is larger or smaller than the original section alignment.
if (Sec->SubalignExpr) {
- uint32_t Subalign = Sec->SubalignExpr().getValue();
+ uint32_t Subalign =
+ std::max((uint64_t)1, Sec->SubalignExpr().getValue());
for (InputSectionBase *S : V)
S->Alignment = Subalign;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38846.119312.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171017/8fb52d0f/attachment.bin>
More information about the llvm-commits
mailing list