Conversation
| ELFSection *InSect = R->getSection(); | ||
| for (Fragment *F : InSect->getFragmentList()) { | ||
| ELFSection *owningSect = F->getOwningSection(); | ||
| if (owningSect && seen.insert(owningSect).second) { |
There was a problem hiding this comment.
early return if either of these are false?
There was a problem hiding this comment.
There is no statement after this if-command, and thus, I am not sure if early return would be beneficial here.
f2715a1 to
23fed03
Compare
quic-seaswara
left a comment
There was a problem hiding this comment.
Reviewed a bit thorougly.
| if (owningSect && seen.insert(owningSect).second) { | ||
| // Warn if SUBALIGN is reducing the section alignment | ||
| if (ThisConfig.showLinkerScriptWarnings() && F->alignment() > subAlign) { | ||
| ThisConfig.raise(Diag::warn_subalign_less_than_section_alignment) |
There was a problem hiding this comment.
Should this be an error ?
There was a problem hiding this comment.
No, as per GNU ld docs (https://sourceware.org/binutils/docs/ld/Forced-Input-Alignment.html), SUBALIGN is allowed to reduce the input section alignment.
| for (Fragment *F : inSect->getFragmentList()) { | ||
| ELFSection *owningSect = F->getOwningSection(); | ||
| if (owningSect->getKind() == LDFileFormat::Kind::OutputSectData) { | ||
| continue; |
There was a problem hiding this comment.
awesome!
Should we do this for internal sections ?
There was a problem hiding this comment.
We may need to take this as case-by-case basis. Most internal sections do indeed represent a section and thus SUBALIGN should affect them. OutputSectData is an exception because it is not a section at all as per GNU ld docs.
a303120 to
a8ac9c6
Compare
a8ac9c6 to
6dbdf27
Compare
|
Ping @quic-seaswara |
This commit fixes the SUBALIGN linker script feature. SUBALIGN feature is used to modify the alignment of all input sections present in an output section. Until now, we were only changing the alignment of the first fragment of each rule of the output sections with SUBALIGN specified. This commit fixes the SUBALIGN behavior. SUBALIGN affects the alignment of the first fragment as is seen by the linker when traversing the output sections for the input sections that may contain more than 1 fragment such as .eh_frame, PLT / GOT sections, and .comment section. Resolves qualcomm#343 Signed-off-by: Parth Arora <partaror@qti.qualcomm.com>
| << utility::toHex(subAlign) << utility::toHex(F->alignment()) | ||
| << owningSect->getLocation(0, ThisConfig.options()); | ||
| } | ||
| F->setAlignment(subAlign); |
There was a problem hiding this comment.
We should do
F->setOwningSection->setAlignment(subAlign) right ?
There was a problem hiding this comment.
No. Fragment::paddingSize() is the key function that determines a fragment's padding requirements and it uses Fragment's alignment instead of the owning input section alignment. In the current design, it seems that we prefer fragment's alignment over the input section's alignment in the layout phase.
This commit fixes the SUBALIGN linker script feature. SUBALIGN feature is used to modify the alignment of all input sections present in an output section. Until now, we were only changing the alignment of the first fragment of each rule of the output sections with SUBALIGN specified. This commit fixes the SUBALIGN behavior.
SUBALIGN affects the alignment of the first fragment as is seen by the linker when traversing the output sections for the input sections that may contain more than 1 fragment such as .eh_frame, PLT / GOT sections, and .comment section.
Resolves #343