[lld] r275374 - Set sh_addralign to 1 instead of 0.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 22:46:24 PDT 2016
Author: ruiu
Date: Thu Jul 14 00:46:24 2016
New Revision: 275374
URL: http://llvm.org/viewvc/llvm-project?rev=275374&view=rev
Log:
Set sh_addralign to 1 instead of 0.
ELF spec says that alignment of 0 is equivalent to 1.
Previously, we arbitrary set to 0 or 1, but always setting to 1
makes our program simpler.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/test/ELF/eh-frame-hdr.s
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=275374&r1=275373&r2=275374&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Jul 14 00:46:24 2016
@@ -37,6 +37,7 @@ OutputSectionBase<ELFT>::OutputSectionBa
memset(&Header, 0, sizeof(Elf_Shdr));
Header.sh_type = Type;
Header.sh_flags = Flags;
+ Header.sh_addralign = 1;
}
template <class ELFT>
@@ -393,7 +394,6 @@ template <class ELFT>
InterpSection<ELFT>::InterpSection()
: OutputSectionBase<ELFT>(".interp", SHT_PROGBITS, SHF_ALLOC) {
this->Header.sh_size = Config->DynamicLinker.size() + 1;
- this->Header.sh_addralign = 1;
}
template <class ELFT> void InterpSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -1247,9 +1247,7 @@ template <class ELFT>
StringTableSection<ELFT>::StringTableSection(StringRef Name, bool Dynamic)
: OutputSectionBase<ELFT>(Name, SHT_STRTAB,
Dynamic ? (uintX_t)SHF_ALLOC : 0),
- Dynamic(Dynamic) {
- this->Header.sh_addralign = 1;
-}
+ Dynamic(Dynamic) {}
// Adds a string to the string table. If HashIt is true we hash and check for
// duplicates. It is optional because the name of global symbols are already
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=275374&r1=275373&r2=275374&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Thu Jul 14 00:46:24 2016
@@ -67,12 +67,9 @@ public:
void setSize(uintX_t Val) { Header.sh_size = Val; }
uintX_t getFlags() const { return Header.sh_flags; }
uintX_t getFileOff() const { return Header.sh_offset; }
- uintX_t getAlignment() const {
- // The ELF spec states that a value of 0 means the section has no alignment
- // constraits.
- return std::max<uintX_t>(Header.sh_addralign, 1);
- }
+ uintX_t getAlignment() const { return Header.sh_addralign; }
uint32_t getType() const { return Header.sh_type; }
+
void updateAlignment(uintX_t Alignment) {
if (Alignment > Header.sh_addralign)
Header.sh_addralign = Alignment;
Modified: lld/trunk/test/ELF/eh-frame-hdr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/eh-frame-hdr.s?rev=275374&r1=275373&r2=275374&view=diff
==============================================================================
--- lld/trunk/test/ELF/eh-frame-hdr.s (original)
+++ lld/trunk/test/ELF/eh-frame-hdr.s Thu Jul 14 00:46:24 2016
@@ -89,7 +89,7 @@ _start:
// HDR-NEXT: Size: 36
// HDR-NEXT: Link: 0
// HDR-NEXT: Info: 0
-// HDR-NEXT: AddressAlignment: 0
+// HDR-NEXT: AddressAlignment: 1
// HDR-NEXT: EntrySize: 0
// HDR-NEXT: SectionData (
// HDR-NEXT: 0000: 011B033B 9CFFFFFF 03000000 480E0000 |
More information about the llvm-commits
mailing list