[ELF] Change some non-null pointer parameters to references. NFC

This commit is contained in:
Fangrui Song
2021-12-22 20:51:11 -08:00
parent a954558e87
commit baa3eb0dd9
8 changed files with 108 additions and 108 deletions

View File

@@ -560,22 +560,22 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
return ret;
}
void LinkerScript::discard(InputSectionBase *s) {
if (s == in.shStrTab || s == mainPart->relrDyn)
error("discarding " + s->name + " section is not allowed");
void LinkerScript::discard(InputSectionBase &s) {
if (&s == in.shStrTab || &s == mainPart->relrDyn)
error("discarding " + s.name + " section is not allowed");
// You can discard .hash and .gnu.hash sections by linker scripts. Since
// they are synthesized sections, we need to handle them differently than
// other regular sections.
if (s == mainPart->gnuHashTab)
if (&s == mainPart->gnuHashTab)
mainPart->gnuHashTab = nullptr;
if (s == mainPart->hashTab)
if (&s == mainPart->hashTab)
mainPart->hashTab = nullptr;
s->markDead();
s->parent = nullptr;
for (InputSection *ds : s->dependentSections)
discard(ds);
s.markDead();
s.parent = nullptr;
for (InputSection *sec : s.dependentSections)
discard(*sec);
}
void LinkerScript::discardSynthetic(OutputSection &outCmd) {
@@ -589,7 +589,7 @@ void LinkerScript::discardSynthetic(OutputSection &outCmd) {
std::vector<InputSectionBase *> matches =
computeInputSections(isd, secs);
for (InputSectionBase *s : matches)
discard(s);
discard(*s);
}
}
}
@@ -618,7 +618,7 @@ void LinkerScript::processSectionCommands() {
// Any input section assigned to it is discarded.
if (osec->name == "/DISCARD/") {
for (InputSectionBase *s : v)
discard(s);
discard(*s);
discardSynthetic(*osec);
osec->commands.clear();
return false;