The --set-section-flags option was being ignored when adding a new
section. Take it into account if present.
Fixes https://llvm.org/PR51244
Differential D106942
[llvm-objcopy] Consider section flags when adding section alfonsosanchezbeato on Jul 28 2021, 3:21 AM. Authored by
Details The --set-section-flags option was being ignored when adding a new Fixes https://llvm.org/PR51244
Diff Detail
Event TimelineComment Actions Could you please add a test case to the existing llvm-objcopy tests (llvm/test/tools/llvm-objcopy) that shows this fix works.
Comment Actions @mstorsjo, could you take a look, please? My COFF knowledge isn't really sufficient to see if there's a better way of doing things. My initial thought is whether a separate later pass should be the one that sets virtual addresses, rather than addSection, but it may not make sense. Comment Actions I think approach is pragmatically sensible here. We don't recalculate and set virtual addresses for all sections, only added ones. (We generally can't change the virtual memory layout of the linked image as there are lots of relative addresses encoded anywhere in the section contents without any relocation marker, as those relocations were fixed at link time. So we can remove sections from the end and add new ones at the end, but we generally can't remove ones in the middle leaving a gap.) So if we split out setting addresses to a separate pass, it would only run over the sections that were added, not all of them. So keeping it in addSection and just checking the flags to set like this patch does, probably is fine.
Comment Actions Oh, also, @alfonsosanchezbeato, please include extra context in the diff when you upload (by doing e.g. git diff -U999) to make it easier to review here. Comment Actions The test looks good to me now, and I've given my opinion on the implementation form, so +1 on this from me now, but I'll let @jhenderson approve if he's ok with it.
Comment Actions FWIW, I was referring specifically to the Characteristics line, but I don't think it matters whether they are there or not for the other lines. LGTM. Comment Actions @ alfonsosanchezbeato - This is approved but not pushed yet - I guess you don't have push access? If you provide your preferred git author line, "Real Name <email@address>", I can push it for you. (Also note @MaskRay 's request for renaming the test, but I guess I can do that before pushing too.) Comment Actions I've renamed the test now. Right, I do not have push access, so I would appreciate if you can do that for me. The author line would be: Author: Alfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com> Thanks, |
Rather than modify flagsToCharacteristics, could you just move this loop above the SetSectionFlags block above?