[linker-script] Error when dot assignment exceeds UINT32_MAX#1116
[linker-script] Error when dot assignment exceeds UINT32_MAX#1116deepakshirkem wants to merge 1 commit into
Conversation
|
Hi @deepakshirkem, Thank you for the pull-request. The original issue does not state that we should error-out if the padding due to dot assignment is greater than UINT32_MAX, instead it is about the symbol values being incorrect when there is a huge padding. Erroring out when there is a huge padding is a workaround and not a fix for this issue. The huge padding in the original issue can be replaced by any other huge-content that takes up space in the image layout and we will still see the same issue. |
parth-07
left a comment
There was a problem hiding this comment.
I have implemented the root cause fix in PR #1108 by changing uint32_t → uint64_t for Fragment::UnalignedOffset
PR #1108 has the right approach but we cannot implement that because of the memory overhead that it may cause. In a large build, there are a LOT of fragments. Increasing the offset size from 4 bytes to 8 bytes does not offer much benefits to justify the memory overhead. @quic-seaswara Do you think we should report error if the dot assignment causes padding greater than UINT32_MAX as this PR is doing?
| if (isDot() && Section) { | ||
| LDSymbol *DotSym = CurModule.getNamePool().findSymbol("."); | ||
| if (DotSym && ExpressionValue > DotSym->value()) { | ||
| uint64_t Padding = ExpressionValue - DotSym->value(); |
There was a problem hiding this comment.
This will not report the error if ExpressionValue < DotSym->value() but the difference between the two is still greater than UINT32_MAX.
There was a problem hiding this comment.
I will reproduce this issue and update the check.
ELD was silently truncating dot assignment values greater than UINT32_MAX causing incorrect section addresses. Added error when dot assignment creates padding that exceeds UINT32_MAX as such large padding values are not valid. Fixes qualcomm#386 Signed-off-by: deepakshirkem <deepakshirke509@gmail.com>
9d8f4c3 to
5a3bee1
Compare
Problem
Fixes #386
ELD assigns incorrect addresses when the padding due to dot assignment is greater than
UINT32_MAX. When a linker script uses:. = . + 0x400000000;Fix
Added validation in
Assignment::assign()to error out when dot assignment creates padding that exceedsUINT32_MAXas such large padding values are not meaningful.
Testing
Added test
DotAssignmentOverflowthat verifies ELD emits a clear error when dot assignment value exceedsUINT32_MAX.cc @quic-seaswara @parth-07