[lld] r244941 - Record the alignment of the output sections.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 13:13:40 PDT 2015
Author: rafael
Date: Thu Aug 13 15:13:39 2015
New Revision: 244941
URL: http://llvm.org/viewvc/llvm-project?rev=244941&view=rev
Log:
Record the alignment of the output sections.
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/elf2/basic.s
lld/trunk/test/elf2/basic32.s
lld/trunk/test/elf2/basic32be.s
lld/trunk/test/elf2/basic64be.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=244941&r1=244940&r2=244941&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Aug 13 15:13:39 2015
@@ -120,8 +120,12 @@ template <class ELFT> void Writer<ELFT>:
template <bool Is64Bits> void OutputSection<Is64Bits>::addChunk(Chunk *C) {
Chunks.push_back(C);
+ uint32_t Align = C->getAlign();
+ if (Align > Header.sh_addralign)
+ Header.sh_addralign = Align;
+
uintX_t Off = Header.sh_size;
- Off = RoundUpToAlignment(Off, C->getAlign());
+ Off = RoundUpToAlignment(Off, Align);
C->setOutputSectionOff(Off);
Off += C->getSize();
Header.sh_size = Off;
Modified: lld/trunk/test/elf2/basic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=244941&r1=244940&r2=244941&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic.s (original)
+++ lld/trunk/test/elf2/basic.s Thu Aug 13 15:13:39 2015
@@ -63,7 +63,7 @@ _start:
# CHECK-NEXT: Size: 16
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -79,7 +79,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -95,7 +95,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
Modified: lld/trunk/test/elf2/basic32.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=244941&r1=244940&r2=244941&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic32.s (original)
+++ lld/trunk/test/elf2/basic32.s Thu Aug 13 15:13:39 2015
@@ -63,7 +63,7 @@ _start:
# CHECK-NEXT: Size: 12
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -79,7 +79,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -95,7 +95,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
Modified: lld/trunk/test/elf2/basic32be.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32be.s?rev=244941&r1=244940&r2=244941&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic32be.s (original)
+++ lld/trunk/test/elf2/basic32be.s Thu Aug 13 15:13:39 2015
@@ -63,7 +63,7 @@ _start:
# CHECK-NEXT: Size: 12
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -79,7 +79,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -95,7 +95,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
Modified: lld/trunk/test/elf2/basic64be.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=244941&r1=244940&r2=244941&view=diff
==============================================================================
--- lld/trunk/test/elf2/basic64be.s (original)
+++ lld/trunk/test/elf2/basic64be.s Thu Aug 13 15:13:39 2015
@@ -68,7 +68,7 @@ _start:
# CHECK-NEXT: Size: 12
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -84,7 +84,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -100,7 +100,7 @@ _start:
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 4
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -116,7 +116,7 @@ _start:
# CHECK-NEXT: Size: 24
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 0
+# CHECK-NEXT: AddressAlignment: 1
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
More information about the llvm-commits
mailing list