[all-commits] [llvm/llvm-project] 332003: [llvm-objcopy] Add change-section-lma *+/-offset (...

Eleanor Bonnici via All-commits all-commits at lists.llvm.org
Mon Jul 8 09:17:31 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3320036370ba3719471ab243f253237e88996495
      https://github.com/llvm/llvm-project/commit/3320036370ba3719471ab243f253237e88996495
  Author: Eleanor Bonnici <eleanor.bonnici at arm.com>
  Date:   2024-07-08 (Mon, 08 Jul 2024)

  Changed paths:
    M llvm/docs/CommandGuide/llvm-objcopy.rst
    M llvm/include/llvm/ObjCopy/CommonConfig.h
    M llvm/lib/ObjCopy/ConfigManager.cpp
    M llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
    A llvm/test/tools/llvm-objcopy/ELF/change-section-lma.test
    M llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
    M llvm/tools/llvm-objcopy/ObjcopyOpts.td

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

llvm-objcopy did not support change-section-lma argument.

This patch adds support for a use case of change-section-lma, that is
shifting load address of all sections by the same offset. This seems to
be the only practical use case of change-section-lma, found in other
software such as Zephyr RTOS's build system.

This is an option that could possibly be supported in some other than
ELF formats, however this change only implements it for ELF. When used
with other formats an error message is raised.

In comparison, the behavior of GNU objcopy is inconsistent. For some ELF
files it behaves the same as described above. For others, it copies the
file without modifying the p_paddr fields when it would be expected. In
some experiments it modifies arbitrary fields in section or program
headers. It is unclear what exactly determines this.
The executable file generated by yaml2obj in this test is not parsable
by GNU objcopy. With Machine set to EM_AARCH64, the file can be parsed
and the first test in the test file completes with 0 exit code. However,
the result is rather arbitrary. AArch64 GNU objcopy subtracts 0x1000
from p_filesz and p_memsz of the first LOAD section and 0x1000 from
p_offset of the second LOAD section. It does not look meaningful.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list