forked from OSchip/llvm-project
[elf2] Correctly handle sections with an alignment of 0. Spec says to treat it as an alignment of 1.
llvm-svn: 246901
This commit is contained in:
parent
b1518d6c24
commit
baae538cc6
|
@ -42,7 +42,11 @@ public:
|
|||
|
||||
// The writer sets and uses the addresses.
|
||||
uintX_t getOutputSectionOff() const { return OutputSectionOff; }
|
||||
uintX_t getAlign() { return Header->sh_addralign; }
|
||||
uintX_t getAlign() {
|
||||
// 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);
|
||||
}
|
||||
void setOutputSectionOff(uint64_t V) { OutputSectionOff = V; }
|
||||
|
||||
void setOutputSection(OutputSection<ELFT> *O) { Out = O; }
|
||||
|
|
|
@ -63,7 +63,11 @@ public:
|
|||
void setSize(uintX_t Val) { Header.sh_size = Val; }
|
||||
uintX_t getFlags() { return Header.sh_flags; }
|
||||
uintX_t getFileOff() { return Header.sh_offset; }
|
||||
uintX_t getAlign() { return Header.sh_addralign; }
|
||||
uintX_t getAlign() {
|
||||
// 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);
|
||||
}
|
||||
uint32_t getType() { return Header.sh_type; }
|
||||
|
||||
virtual void finalize() {}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# RUN: yaml2obj -format elf %s -o %t
|
||||
# RUN: lld -flavor gnu2 %t -o %tout
|
||||
|
||||
# Verify that lld can handle sections with an alignment of zero.
|
||||
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_X86_64
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
AddressAlign: 0
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: _start
|
||||
Section: .text
|
Loading…
Reference in New Issue