[ELF] Remove unneeded getOutputSectionVA. NFC
authorFangrui Song <i@maskray.me>
Mon, 29 Nov 2021 00:17:10 +0000 (16:17 -0800)
committerFangrui Song <i@maskray.me>
Mon, 29 Nov 2021 00:17:10 +0000 (16:17 -0800)
I attempted to remove it 1 or 2 year ago but kept it just to have a good
diagnostic in case the output section is nullptr (should be impossible).
It is long enough that we haven't seen such a case.

lld/ELF/LinkerScript.cpp

index 9de5125ff8699acf2502f910d1e0f2d965e8440b..054944e76e9eee5b4a9ac52d1b30e5b80460027c 100644 (file)
@@ -53,12 +53,6 @@ static bool isSectionPrefix(StringRef prefix, StringRef name) {
   return name.startswith(prefix) || name == prefix.drop_back();
 }
 
-static uint64_t getOutputSectionVA(SectionBase *sec) {
-  OutputSection *os = sec->getOutputSection();
-  assert(os && "input section has no output section assigned");
-  return os ? os->addr : 0;
-}
-
 static StringRef getOutputSectionName(const InputSectionBase *s) {
   if (config->relocatable)
     return s->name;
@@ -118,15 +112,13 @@ static StringRef getOutputSectionName(const InputSectionBase *s) {
 
 uint64_t ExprValue::getValue() const {
   if (sec)
-    return alignTo(sec->getOffset(val) + getOutputSectionVA(sec),
+    return alignTo(sec->getOutputSection()->addr + sec->getOffset(val),
                    alignment);
   return alignTo(val, alignment);
 }
 
 uint64_t ExprValue::getSecAddr() const {
-  if (sec)
-    return sec->getOffset(0) + getOutputSectionVA(sec);
-  return 0;
+  return sec ? sec->getOutputSection()->addr + sec->getOffset(0) : 0;
 }
 
 uint64_t ExprValue::getSectionOffset() const {