Put PUBLIC lines in Mac symbol files.

Exported symbols on Mach-O binaries are defined in a STABS section. This patch makes stabs_reader handle them, adds support for Extern symbols in the Module class (which are output as PUBLIC lines in symbol files), and the proper processing in stabs_to_module to hook it all up.

A=mark R=jimb at http://breakpad.appspot.com/163001 and http://breakpad.appspot.com/267001

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@778 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
ted.mielczarek
2011-03-04 16:08:39 +00:00
parent 68b256aed3
commit bf25801d83
9 changed files with 270 additions and 11 deletions

View File

@@ -74,6 +74,35 @@ TEST(StabsToModule, SimpleCU) {
EXPECT_EQ(174823314, line->number);
}
#ifdef __GNUC__
// Function name mangling can vary by compiler, so only run mangled-name
// tests on GCC for simplicity's sake.
TEST(StabsToModule, Externs) {
Module m("name", "os", "arch", "id");
StabsToModule h(&m);
// Feed in a few Extern symbols.
EXPECT_TRUE(h.Extern("_foo", 0xffff));
EXPECT_TRUE(h.Extern("__Z21dyldGlobalLockAcquirev", 0xaaaa));
EXPECT_TRUE(h.Extern("_MorphTableGetNextMorphChain", 0x1111));
h.Finalize();
// Now check to see what has been added to the Module.
vector<Module::Extern *> externs;
m.GetExterns(&externs, externs.end());
ASSERT_EQ((size_t) 3, externs.size());
Module::Extern *extern1 = externs[0];
EXPECT_STREQ("MorphTableGetNextMorphChain", extern1->name.c_str());
EXPECT_EQ((Module::Address)0x1111, extern1->address);
Module::Extern *extern2 = externs[1];
EXPECT_STREQ("dyldGlobalLockAcquire()", extern2->name.c_str());
EXPECT_EQ((Module::Address)0xaaaa, extern2->address);
Module::Extern *extern3 = externs[2];
EXPECT_STREQ("foo", extern3->name.c_str());
EXPECT_EQ((Module::Address)0xffff, extern3->address);
}
#endif // __GNUC__
TEST(StabsToModule, DuplicateFunctionNames) {
Module m("name", "os", "arch", "id");
StabsToModule h(&m);
@@ -154,6 +183,9 @@ TEST(InferSizes, LineSize) {
EXPECT_EQ(87660088, line2->number);
}
#ifdef __GNUC__
// Function name mangling can vary by compiler, so only run mangled-name
// tests on GCC for simplicity's sake.
TEST(FunctionNames, Mangled) {
Module m("name", "os", "arch", "id");
StabsToModule h(&m);
@@ -188,6 +220,7 @@ TEST(FunctionNames, Mangled) {
EXPECT_EQ(0U, function->parameter_size);
ASSERT_EQ(0U, function->lines.size());
}
#endif // __GNUC__
// The GNU toolchain can omit functions that are not used; however,
// when it does so, it doesn't clean up the debugging information that