[PATCH] D63003: [ELF] Don't emit dynamic relocations with weak undef in writable sections

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 04:18:40 PDT 2019


ruiu added a comment.

Does this mean that we previously emit a dynamic relocation for a weak undefined symbol that couldn't have been resolved at link time, and this patch changes the behavior so that weak undefined symbols must be resolved to some symbol at link time. Am I correct?

If so, that change seems a little risky, as it will silently change a program behavior. If the following three conditions are met, a program will behave differently.

1. An object file contains a weak undefined symbol
2. No DSOs define the weak undefined symbol at link time
3. But some DSO defines the weak undefined symbol at run time

I'd think that the above conditions are minor, and you generally shouldn't rely on that kind of edge cases, though.

Ultimately, it seems like it is ultimately a programming language and ELF's failure that they underrepresents the difference between global variables defined in other modules and global variables defined in the same module. The ELF's model tries to hide the difference between static linking and dynamic linking, but the difference leaks at various places like this. We have only one type of "weak" undefined type, but in dynamic linking, a symbol is given two chances to be resolved (static link time and run time),  so it is hard to say what is a correct behavior.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D63003





More information about the llvm-commits mailing list