[PATCH] D153381: [llvm-objcopy] -O binary: do not align physical addresses

Alexey Karyakin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 20 15:16:44 PDT 2023


quic-akaryaki created this revision.
Herald added subscribers: hiraditya, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: jhenderson.
Herald added a project: All.
quic-akaryaki requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

llvm-objcopy should not insert padding before a section if its
physical addresses is not aligned to section's alignment. This
behavior will match GNU objcopy and is important for embedded images
where the physical address is used to store the initial data image.
The loader typically will copy this image using a start symbol
created by the linker. If llvm-objcopy inserts padding before such a
section, the symbol address will not match the location in the image.

This commit refines the change in https://reviews.llvm.org/D128961
which intended to align sections which type changed from NOBITS and
their offset may not be aligned. However, it affected all sections.

Fix https://github.com/llvm/llvm-project/issues/62636


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153381

Files:
  llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153381.533059.patch
Type: text/x-patch
Size: 4428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230620/3826f50e/attachment.bin>


More information about the llvm-commits mailing list