[dsymutil] Gather global and local symbol addresses in the main executable.
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 30 Nov 2018 18:56:10 +0000 (18:56 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 30 Nov 2018 18:56:10 +0000 (18:56 +0000)
commitd1c9751657c81d015a994c407be9ec57245736d7
treeb27a1b454e36b158c3f722c7752bb933edc72187
parentcd5115b74dcbd284064cf793d7c9024ae3233db1
[dsymutil] Gather global and local symbol addresses in the main executable.

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
llvm/test/tools/dsymutil/Inputs/global_downgraded_to_static.x86_64 [new file with mode: 0755]
llvm/test/tools/dsymutil/Inputs/global_downgraded_to_static/1.o [new file with mode: 0644]
llvm/test/tools/dsymutil/Inputs/global_downgraded_to_static/1.r.o [new file with mode: 0644]
llvm/test/tools/dsymutil/Inputs/global_downgraded_to_static/2.o [new file with mode: 0644]
llvm/test/tools/dsymutil/X86/global_downgraded_to_static.c [new file with mode: 0644]
llvm/tools/dsymutil/MachODebugMapParser.cpp