Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always emit symbols like _GLOBAL_OFFSET_TABLE_, _PROCEDURE_LINKAGE_TABLE_ and others #308

Open
marxin opened this issue Jan 14, 2025 · 2 comments

Comments

@marxin
Copy link
Collaborator

marxin commented Jan 14, 2025

I noticed these symbols are always emitted by the Mold linker and the presence of the symbols seems to me pretty hand when it comes to disassembly:

$ cat lib.c
void foo() {
  __builtin_printf("xxx\n");
}
$ gcc lib.c -fPIC -shared -o lib.so -fuse-ld=mold
$ readelf -sW lib.so
...
    67: 00000000000026f0     0 NOTYPE  LOCAL  DEFAULT   19 _DYNAMIC
    68: 00000000000028e8     0 NOTYPE  LOCAL  DEFAULT   21 _GLOBAL_OFFSET_TABLE_
    69: 00000000000015e0     0 NOTYPE  LOCAL  DEFAULT   16 _PROCEDURE_LINKAGE_TABLE_
...
    81: 0000000000000000     0 TLS     LOCAL  DEFAULT    1 _TLS_MODULE_BASE_

On the other hand, the Wild linker does not emit these symbols.

@davidlattimore
Copy link
Owner

For the most part, I've tried to make Wild match GNU ld as closely as possible. However, it seems reasonable to me to add extra symbols if they're useful for diagnostic purposes, especially given that another linker does it. So adding them sounds good to me

@marxin
Copy link
Collaborator Author

marxin commented Jan 19, 2025

From debugging point of view, it's even more convenient for symbols like this:

   37: 00000000000015f0      0 FUNC    LOCAL  DEFAULT       14 __cxa_finalize$pltgot
   38: 000000000000c4e0      0 OBJECT  LOCAL  DEFAULT       20 __gmon_start__$got
   39: 000000000000c4e8      0 OBJECT  LOCAL  DEFAULT       20 _ITM_deregisterTMCloneTable$got
   40: 000000000000c4f0      0 OBJECT  LOCAL  DEFAULT       20 _ITM_registerTMCloneTable$got
   41: 000000000000c508      0 OBJECT  LOCAL  DEFAULT       20 __cxa_finalize$got
   42: 000000000000c4f8      0 OBJECT  LOCAL  DEFAULT       20 foo$tlsdesc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants