Remove copy relocation and optimize locally defined symbol access
Remove copy relocation, add canonical function address and optimize locally defined symbol access:
- All accesses to protected definitions are local access.
- In executable, all accesses to defined symbols are local access.
- All global function pointers, whose function bodies aren't locally defined, must use GOT.
- All read/write accesses to symbols, which aren't locally defined, must use GOT.
- Branches to undefined symbols may use PLT.
These should be enforced by
- Compiler: Add a compiler option, -fsingle-global-definition.
- Implemented on users/hjl/pr35513/master branch: https://gitlab.com/x86-gcc/gcc/-/tree/users/hjl/pr35513/master
- Binutils:
- Assembler: Add a marker to indicate that relocatable output requires such a feature to work correctly.
- Linker: Add a marker by merging markers on all relocatable inputs to indicate that the linker output requires such a feature to work correctly.
- Implemented on users/hjl/property/master branch: https://gitlab.com/x86-binutils/binutils-gdb/-/tree/users/hjl/property/master
- ld.so: Scan the marker on all components, the executable and its dependency shared libraries.
- When performing symbol lookup for references in an object without single global definition:
-
Disallow copy relocations against protected data symbols in an object with single global definition. -
Disallow non-zero symbol values of undefined function symbols, which are used as the function pointer, against protected function symbols in an object with single global definition. - Implemented on users/hjl/single-global/master branch: https://gitlab.com/x86-glibc/glibc/-/commits/users/hjl/single-global/master
Edited by H.J. Lu