Alpha: Properly handle local weak undefined symbols
The linker now correctly handles local weak undefined symbols on Alpha, fixing a runtime error.
AddressSanitizer (ASan) reported a runtime error due to a null pointer dereference when handling local weak undefined symbols in the Alpha linker. This commit fixes the error by adding a null check before accessing the symbol’s properties, resolving the ASan complaint and fixing TLS-related linking failures. This prevents crashes and ensures correct linking behavior in specific scenarios involving weak symbols and TLS.
In Details
The commit addresses an ASan warning in elf64_alpha_relocate_section due to accessing h->root.root.root.string when h is NULL. This occurs when dealing with local weak undefined symbols. The fix adds a check for NULL h before accessing h->root in elf_link_local_undefweak_p. This condition can arise during relocation processing for Alpha binaries.
For Context
When linking code, the linker needs to resolve references to symbols defined in other parts of the program or in external libraries. A weak symbol is a symbol that can be overridden by another symbol with the same name. This commit fixes a bug in the Alpha linker that occurs when handling local undefined weak symbols, which are symbols that are declared but not defined in the current module. The fix prevents a crash due to a null pointer dereference during relocation.