[PATCH] x86: Keep __patchable_function_entries sections with --gc-sections

Fangrui Song i@maskray.me
Sat Feb 1 17:34:00 GMT 2020


On 2020-02-01, H.J. Lu wrote:
>After all text sections have been garbage collected, if a
>__patchable_function_entries section references a section which
>wasn't marked, mark it with SEC_EXCLUDE and return NULL.  Otherwise,
>keep it.
>
>Should it be handled in _bfd_elf_gc_mark_extra_sections?

Thanks for paying attention to these feature requests.

I referenced GNU as and ld requests at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93492#c2
If we

* implement SHF_LINK_ORDER
* allow multiple sections with the same name ("unique")
* teach GCC to use SHF_LINK_ORDER and "unique" (see https://gcc.gnu.org/ml/gcc/2020-01/msg00067.html)

An ad-hoc gc marking will be unnecessary.

SHF_LINK_ORDER has been used in a few sanitizers. Now we know
__patchable_function_entries can benefit from it.  In the future, they
may be instances. We really need a general solution.



More information about the Binutils mailing list