[PATCH] D74736: [ELF] Ignore the maximum of input section alignments for two cases
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 10:01:39 PST 2020
psmith added a comment.
I agree with the specification of the change, I'm not sure why there is a change in Writer.cpp yet, if there is a good reason and it isn't obvious it will be worth a comment.
================
Comment at: lld/ELF/Writer.cpp:2219
+ return;
+ cmd->alignExpr = [align = cmd->alignment]() { return align; };
+ if (!cmd->addrExpr) {
----------------
I'm struggling a bit with this one from the just the context. As far as I can tell there are only two uses of AlignExpr, in switchTo and in
`void LinkerScript::adjustSectionsBeforeSorting()`
````
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
if (sec->alignExpr)
sec->alignment =
std::max<uint32_t>(sec->alignment, sec->alignExpr().getValue());
```
In both cases I can't easily see why adding `cmd->alignExpr = [align = cmd->alignment]() { return align; };` would change the calculated alignment. For example `sec->alignment` should be the same as `alignExpr().getValue()` and in `switchTo`
```
uint32_t align =
sec->alignExpr ? sec->alignExpr().getValue() : ctx->outSec->alignment;
```
When there isn't alignExpr isn't `ctx->outSec->alignment` the same as `alignExpr.getValue()`?
Can you let me know if I'm missing something?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74736/new/
https://reviews.llvm.org/D74736
More information about the llvm-commits
mailing list