[PATCH] D150859: [llvm-objcopy][ELF] Preserve sh_link to .symtab when applicable

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 07:25:04 PDT 2023


MaskRay added a comment.

In D150859#4376058 <https://reviews.llvm.org/D150859#4376058>, @andrewng wrote:

>>>> I have a comment whether we should make new symbols (while existing symbol indices are unchanged) reset `sh_link` to zero.
>>>
>>> I did consider this but decided not to reset `sh_link` to `0`. Do you have a reason for why resetting `sh_link` to `0` in this scenario would be better/preferable?
>>
>> The section content may be a digest of existing symbols. Adding a symbol nullifies its assumption that its content is comprehensive.
>> However, I don't have an example that this breaks.
>
> Yes, the number of symbols could differ. I guess resetting `sh_link` to `0` would be the safer option but on the other hand if the user is making such modifications then it could be considered at their own risk.

Thanks. The argument for not resetting `sh_link` to 0 for `--add-symbol` looks good to me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150859/new/

https://reviews.llvm.org/D150859



More information about the llvm-commits mailing list