[llvm] [llvm-objcopy] Add change-section-lma *+/-offset (PR #95431)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 00:41:52 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) +
----------------
jh7370 wrote:

For this and the similar error below, I think it would be useful to give a little more context to the error, something like "would overflow when adjusting by <value>".

https://github.com/llvm/llvm-project/pull/95431


More information about the llvm-commits mailing list