[lld] e80a0b3 - [ELF] Remove unneeded getOutputSectionVA. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 28 16:17:15 PST 2021
Author: Fangrui Song
Date: 2021-11-28T16:17:10-08:00
New Revision: e80a0b353c31e2303c44141ab8b2ca63627ab5c2
URL: https://github.com/llvm/llvm-project/commit/e80a0b353c31e2303c44141ab8b2ca63627ab5c2
DIFF: https://github.com/llvm/llvm-project/commit/e80a0b353c31e2303c44141ab8b2ca63627ab5c2.diff
LOG: [ELF] Remove unneeded getOutputSectionVA. NFC
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.
Added:
Modified:
lld/ELF/LinkerScript.cpp
Removed:
################################################################################
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 9de5125ff869..054944e76e9e 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -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 {
More information about the llvm-commits
mailing list