Changeset View
Changeset View
Standalone View
Standalone View
ELF/SyntheticSections.cpp
Show First 20 Lines • Show All 3,038 Lines • ▼ Show 20 Lines | void elf::mergeSections() { | ||||
std::vector<InputSectionBase *> &V = InputSections; | std::vector<InputSectionBase *> &V = InputSections; | ||||
V.erase(std::remove(V.begin(), V.end(), nullptr), V.end()); | V.erase(std::remove(V.begin(), V.end(), nullptr), V.end()); | ||||
} | } | ||||
MipsRldMapSection::MipsRldMapSection() | MipsRldMapSection::MipsRldMapSection() | ||||
: SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, Config->Wordsize, | : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, Config->Wordsize, | ||||
".rld_map") {} | ".rld_map") {} | ||||
ARMExidxSentinelSection::ARMExidxSentinelSection() | const uint8_t ARMExidxSyntheticSection::Data[8] = { | ||||
0, 0, 0, 0, // PREL31 to target | |||||
1, 0, 0, 0}; // EXIDX_CANTUNWIND | |||||
ARMExidxSyntheticSection::ARMExidxSyntheticSection(InputSection *Link) | |||||
: SyntheticSection(SHF_ALLOC | SHF_LINK_ORDER, SHT_ARM_EXIDX, | : SyntheticSection(SHF_ALLOC | SHF_LINK_ORDER, SHT_ARM_EXIDX, | ||||
Config->Wordsize, ".ARM.exidx") {} | Config->Wordsize, ".ARM.exidx"), | ||||
LinkSec(Link) { | |||||
IsSentinel = Link == nullptr; | |||||
ruiu: You are assigning a `nullptr` to a boolean member.
Who sets IsSentinel to true? Looks like… | |||||
peter.smithAuthorUnsubmitted I don't think I am as the == will have higher precedence than the =. However I should find another way of expressing it. The simplest way is to put some parentheses around so that it is IsSentinel = (Link == nullptr); What I need is a way of distinguishing between the Sentinel (so I can write the address of the end of the section). We do know that at at construction time as the Sentinel won't have a Section to link to at construction time as we don't know what it will be yet, in all other cases we do know. Alternatives:
Any preferences? peter.smith: I don't think I am as the == will have higher precedence than the =. However I should find… | |||||
ruiuUnsubmitted Not Done ReplyInline ActionsApologies, I misread == as =. I'm reading this patch again. ruiu: Apologies, I misread `==` as `=`. I'm reading this patch again. | |||||
RawData = Data; | |||||
} | |||||
// Write a terminating sentinel entry to the end of the .ARM.exidx table. | // Write a EXIDX_CANTUNWIND entry to the .ARM.exidx table. This will either be | ||||
// This section will have been sorted last in the .ARM.exidx table. | // a terminating sentinel entry or a synthetic entry for a code section that | ||||
// had no exception tables. | |||||
// The sentinel section will have been sorted last in the .ARM.exidx table. | |||||
// This table entry will have the form: | // This table entry will have the form: | ||||
// | PREL31 upper bound of code that has exception tables | EXIDX_CANTUNWIND | | // | PREL31 upper bound of code that has exception tables | EXIDX_CANTUNWIND | | ||||
// The sentinel must have the PREL31 value of an address higher than any | // The sentinel must have the PREL31 value of an address higher than any | ||||
// address described by any other table entry. | // address described by any other table entry. | ||||
void ARMExidxSentinelSection::writeTo(uint8_t *Buf) { | // A synthetic table entry will have the form: | ||||
assert(Highest); | // | PREL31 start of LinkSec | EXIDX_CANTUNWIND | | ||||
uint64_t S = Highest->getVA(Highest->getSize()); | void ARMExidxSyntheticSection::writeTo(uint8_t *Buf) { | ||||
uint64_t S = | |||||
IsSentinel ? LinkSec->getVA(LinkSec->getSize()) : LinkSec->getVA(); | |||||
uint64_t P = getVA(); | uint64_t P = getVA(); | ||||
Target->relocateOne(Buf, R_ARM_PREL31, S - P); | Target->relocateOne(Buf, R_ARM_PREL31, S - P); | ||||
write32le(Buf + 4, 1); | write32le(Buf + 4, 1); | ||||
} | } | ||||
// The sentinel has to be removed if there are no other .ARM.exidx entries. | // The sentinel has to be removed if there are no other .ARM.exidx entries. | ||||
bool ARMExidxSentinelSection::empty() const { | bool ARMExidxSyntheticSection::empty() const { | ||||
for (InputSection *IS : getInputSections(getParent())) | for (InputSection *IS : getInputSections(getParent())) | ||||
if (!isa<ARMExidxSentinelSection>(IS)) | if (!isa<ARMExidxSyntheticSection>(IS)) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
} | } | ||||
bool ARMExidxSentinelSection::classof(const SectionBase *D) { | bool ARMExidxSyntheticSection::classof(const SectionBase *D) { | ||||
return D->kind() == InputSectionBase::Synthetic && D->Type == SHT_ARM_EXIDX; | return D->kind() == InputSectionBase::Synthetic && D->Type == SHT_ARM_EXIDX; | ||||
} | } | ||||
ThunkSection::ThunkSection(OutputSection *OS, uint64_t Off) | ThunkSection::ThunkSection(OutputSection *OS, uint64_t Off) | ||||
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, | : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, | ||||
Config->Wordsize, ".text.thunk") { | Config->Wordsize, ".text.thunk") { | ||||
this->Parent = OS; | this->Parent = OS; | ||||
this->OutSecOff = Off; | this->OutSecOff = Off; | ||||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |
You are assigning a nullptr to a boolean member.
Who sets IsSentinel to true? Looks like there's no code doing that.