This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by quic-akaryaki on Jun 20 2023, 3:16 PM.

Details

Summary

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.

This is an updated version of https://reviews.llvm.org/D150276, with
a fix to a test endianness issue.

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

Diff Detail

Event Timeline

quic-akaryaki created this revision.Jun 20 2023, 3:16 PM
quic-akaryaki requested review of this revision.Jun 20 2023, 3:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 3:16 PM

This change fixes an endianness issue with the test in https://reviews.llvm.org/D150276.

quic-akaryaki edited the summary of this revision. (Show Details)Jun 20 2023, 3:22 PM
quic-akaryaki abandoned this revision.Jun 20 2023, 3:26 PM

I'll update the original one.