diff options
author | Fangrui Song <i@maskray.me> | 2024-01-22 09:09:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 09:09:46 -0800 |
commit | 43b13341fbbb718223484a79a539a3c13062f39f (patch) | |
tree | 92f8a1bda0684ca578f57d8d35d6f9579fd9cc05 /lld/ELF/ScriptParser.cpp | |
parent | a859df3b0a099648ec4cd305f22c87ea12ebaac9 (diff) | |
download | llvm-43b13341fbbb718223484a79a539a3c13062f39f.zip llvm-43b13341fbbb718223484a79a539a3c13062f39f.tar.gz llvm-43b13341fbbb718223484a79a539a3c13062f39f.tar.bz2 |
[ELF] Add internal InputFile (#78944)
Based on https://reviews.llvm.org/D45375 . Introduce a new InputFile
kind `InternalKind`, use it for
* `ctx.internalFile`: for linker-defined symbols and some synthesized
`Undefined`
* `createInternalFile`: for symbol assignments and --defsym
I picked "internal" instead of "synthetic" to avoid confusion with
SyntheticSection.
Currently a symbol's file is one of: nullptr, ObjKind, SharedKind,
BitcodeKind, BinaryKind. Now it's non-null (I plan to add an
`assert(file)` to Symbol::Symbol and change `toString(const InputFile
*)`
separately).
Debugging and error reporting gets improved. The immediate user-facing
difference is more descriptive "File" column in the --cref output. This
patch may unlock further simplification.
Currently each symbol assignment gets its own
`createInternalFile(cmd->location)`. Two symbol assignments in a linker
script do not share the same file. Making the file the same would be
nice, but would require non trivial code.
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 4fdb8c7..dd69916 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -288,7 +288,8 @@ void ScriptParser::readDefsym(StringRef name) { Expr e = readExpr(); if (!atEOF()) setError("EOF expected, but got " + next()); - auto *cmd = make<SymbolAssignment>(name, e, 0, getCurrentLocation()); + auto *cmd = make<SymbolAssignment>( + name, e, 0, getCurrentMB().getBufferIdentifier().str()); script->sectionCommands.push_back(cmd); } |