Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dsymutil] Gather global and local symbol addresses in the main execu…
…table. Usually local symbols will have their address described in the debug map. Global symbols have to have their address looked up in the symbol table of the main executable. By playing with 'ld -r' and export lists, you can get a symbol described as global by the debug map while actually being a local symbol as far as the link in concerned. By gathering the address of local symbols, we fix this issue. Also, we prefer a global symbol in case of a name collision to preserve the previous behavior. Note that using the 'ld -r' tricks, people can actually cause symbol names collisions that dsymutil has no way to figure out. This fixes the simple case where there is only one symbol of a given name. rdar://problem/32826621 Differential revision: https://reviews.llvm.org/D54922 llvm-svn: 348021
- Loading branch information
1 parent
cd5115b
commit d1c9751
Showing
6 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
llvm/test/tools/dsymutil/X86/global_downgraded_to_static.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// REQUIRES : system-darwin | ||
// RUN: dsymutil -oso-prepend-path %p/.. -dump-debug-map %p/../Inputs/global_downgraded_to_static.x86_64 2>&1 | FileCheck %s | ||
// | ||
// To build: | ||
// clang -g -c -DFILE1 global_downgraded_to_static.c -o 1.o | ||
// clang -g -c -DFILE2 global_downgraded_to_static.c -o 2.o | ||
// ld -r -exported_symbol _foo 1.o -o 1.r.o | ||
// clang 1.r.o 2.o -o global_downgraded_to_static.x86_64 | ||
|
||
#if defined(FILE1) | ||
int global_to_become_static = 42; | ||
// CHECK: sym: _global_to_become_static, | ||
// CHECK-SAME: binAddr: 0x0000000100001000 | ||
int foo() { | ||
return global_to_become_static; | ||
} | ||
#elif defined(FILE2) | ||
int foo(void); | ||
int main() { | ||
return foo(); | ||
} | ||
#else | ||
#error Define FILE1 or FILE2 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters