[llvm] [llvm-objcopy] Add change-section-lma *+/-offset (PR #95431)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 01:06:45 PDT 2024
================
@@ -670,6 +670,13 @@ static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
}
}
+ if (Config.ChangeSectionLMAValAll != 0) {
+ for (auto &Seg : Obj.segments()) {
+ if (Seg.FileSize > 0)
----------------
jh7370 wrote:
I've given this a bit of thought, and I think it's right that we don't modify the address of empty segments, but ONLY when they have an address of 0 too. Empty segment addresses are mostly there to indicate where they might be if they had a section in them, so I think it makes sense to update their addresses too. However, zero-addressed empty segments don't have the same.
Also, I don't think segments that are nested should be impacted directly (they should move with their parent's address, much like their offset moves with their parent). Non-PT_LOAD top-level segments shouldn't be impacted by this, but we could possibly just special case them when they have a zero address only.
https://github.com/llvm/llvm-project/pull/95431
More information about the llvm-commits
mailing list