[PATCH 1/3] ld/ELF: Move -z dynamic-undefined-weak flag handling to elf.em

Hakan Candar hakan@envs.net
Wed Jul 23 10:40:52 GMT 2025


>Each backend currently implements its own undefined symbol promotion
>logic (often retaining undefweaks) in `elf_<backend>_allocate_dynrelocs`.
>However, that can be overriden by elflink in the above function, if flag
>was passed.
>
>Thoughts? Should we standardize on one of the two as the default,
>or preserve current backend-specific behavior?
>
>Best regards,
>Hakan

Hi H.J.,

Just following up on this patch and my earlier reply.

My main goal with this patch is to make weak and non-weak undefined
symbol handling consistent. Right now, BFD's behavior depends heavily on
the target, and it is difficult to reason whether an undefined symbol
will be kept as a dynamic relocation or dropped entirely.

This patch adds a uniform way to opt into or out of retaining undefineds
with `-z [no]dynamic-undefined-weak`, across all ELF targets. The
default remains backend-specific (value -1), so no behavior changes
unless the user explicitly requests it.

I mentioned some rough edges in the cover letter, and I plan to follow
up with incremental patches to fix those backend issues one by one.

Unless there is a strong reason to pick a global default now, I’d prefer
to keep this series as-is and move forward with the current behavior.

Let me know if that works or if anything needs to change.

Best,
Hakan


More information about the Binutils mailing list