-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[llvm][yaml2obj] Modify section header overriding timing #130942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
701efbe
f079240
9260c30
db32881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -206,6 +206,9 @@ template <class ELFT> class ELFState { | |||||
NameToIdxMap DynSymN2I; | ||||||
ELFYAML::Object &Doc; | ||||||
|
||||||
std::vector<std::pair<unsigned, ELFYAML::Section>> | ||||||
SectionHeadersOverrideHelper; | ||||||
|
||||||
StringSet<> ExcludedSectionHeaders; | ||||||
|
||||||
uint64_t LocationCounter = 0; | ||||||
|
@@ -226,6 +229,7 @@ template <class ELFT> class ELFState { | |||||
StringRef SecName, ELFYAML::Section *YAMLSec); | ||||||
void initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, | ||||||
ContiguousBlobAccumulator &CBA); | ||||||
void overrideSectionHeaders(std::vector<Elf_Shdr> &SHeaders); | ||||||
void initSymtabSectionHeader(Elf_Shdr &SHeader, SymtabType STType, | ||||||
ContiguousBlobAccumulator &CBA, | ||||||
ELFYAML::Section *YAMLSec); | ||||||
|
@@ -845,7 +849,7 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, | |||||
} | ||||||
|
||||||
LocationCounter += SHeader.sh_size; | ||||||
overrideFields<ELFT>(Sec, SHeader); | ||||||
SectionHeadersOverrideHelper.push_back({SN2I.get(Sec->Name), *Sec}); | ||||||
continue; | ||||||
} | ||||||
|
||||||
|
@@ -899,12 +903,17 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, | |||||
} | ||||||
|
||||||
LocationCounter += SHeader.sh_size; | ||||||
|
||||||
// Override section fields if requested. | ||||||
overrideFields<ELFT>(Sec, SHeader); | ||||||
SectionHeadersOverrideHelper.push_back({SN2I.get(Sec->Name), *Sec}); | ||||||
} | ||||||
} | ||||||
|
||||||
template <class ELFT> | ||||||
void ELFState<ELFT>::overrideSectionHeaders(std::vector<Elf_Shdr> &SHeaders) { | ||||||
for (std::pair<unsigned, ELFYAML::Section> &IndexAndSec : | ||||||
SectionHeadersOverrideHelper) | ||||||
overrideFields<ELFT>(&IndexAndSec.second, SHeaders[IndexAndSec.first]); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would just be simpler to update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
} | ||||||
|
||||||
template <class ELFT> | ||||||
void ELFState<ELFT>::assignSectionAddress(Elf_Shdr &SHeader, | ||||||
ELFYAML::Section *YAMLSec) { | ||||||
|
@@ -2090,6 +2099,9 @@ bool ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc, | |||||
// Now we can decide segment offsets. | ||||||
State.setProgramHeaderLayout(PHeaders, SHeaders); | ||||||
|
||||||
// Override section fields if requested. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(and reflow to column width rules of course) |
||||||
State.overrideSectionHeaders(SHeaders); | ||||||
|
||||||
bool ReachedLimit = CBA.getOffset() > MaxSize; | ||||||
if (Error E = CBA.takeLimitError()) { | ||||||
// We report a custom error message instead below. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling to follow why you can't just store
Sec
andSHeader
in the vector (SHeader
as a pointer, obviously)?