[llvm] [llvm-objcopy] Add change-section-lma *+/-offset (PR #95431)
Eleanor Bonnici via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 03:58:12 PDT 2024
================
@@ -670,6 +670,27 @@ static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
}
}
+ if (Config.ChangeSectionLMAValAll != 0) {
+ for (Segment &Seg : Obj.segments()) {
+ if (Seg.FileSize > 0) {
+ if (Config.ChangeSectionLMAValAll > 0 &&
+ Seg.PAddr > std::numeric_limits<uint64_t>::max() -
+ Config.ChangeSectionLMAValAll) {
+ return createStringError(errc::invalid_argument,
+ "address 0x" + Twine::utohexstr(Seg.PAddr) +
+ " would overflow");
+ } else if (Config.ChangeSectionLMAValAll < 0 &&
+ Seg.PAddr < std::numeric_limits<uint64_t>::min() -
+ Config.ChangeSectionLMAValAll)
+ return createStringError(errc::invalid_argument,
+ "address 0x" + Twine::utohexstr(Seg.PAddr) +
+ " would underflow");
+ else
----------------
eleanor-arm wrote:
The coding standard actually discourages use of `else` after return, so I've removed it. And I've added braces around the previous `else if` because the control flow is "deeply nested".
https://github.com/llvm/llvm-project/pull/95431
More information about the llvm-commits
mailing list