aboutsummaryrefslogtreecommitdiff
path: root/src/common/module_unittest.cc
diff options
context:
space:
mode:
authorted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2011-03-04 16:08:39 +0000
committerted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2011-03-04 16:08:39 +0000
commitbf25801d837b8fc496bf9c3a34eac525d8a3d8ae (patch)
treeeefc9e418e10864c47cf9055ddf97a79f8a38979 /src/common/module_unittest.cc
parentUpdating to ints from unsigned ints so -1 will be an acceptable value. (diff)
downloadbreakpad-bf25801d837b8fc496bf9c3a34eac525d8a3d8ae.tar.xz
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
Diffstat (limited to 'src/common/module_unittest.cc')
-rw-r--r--src/common/module_unittest.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/common/module_unittest.cc b/src/common/module_unittest.cc
index 24189944..63ad5056 100644
--- a/src/common/module_unittest.cc
+++ b/src/common/module_unittest.cc
@@ -455,3 +455,62 @@ TEST(Construct, FunctionsWithSameAddress) {
" _without_form\n",
contents.c_str());
}
+
+// Externs should be written out as PUBLIC records, sorted by
+// address.
+TEST(Construct, Externs) {
+ FILE *f = checked_tmpfile();
+ Module m(MODULE_NAME, MODULE_OS, MODULE_ARCH, MODULE_ID);
+
+ // Two externs.
+ Module::Extern *extern1 = new(Module::Extern);
+ extern1->address = 0xffff;
+ extern1->name = "_abc";
+ Module::Extern *extern2 = new(Module::Extern);
+ extern2->address = 0xaaaa;
+ extern2->name = "_xyz";
+
+ m.AddExtern(extern1);
+ m.AddExtern(extern2);
+
+ m.Write(f);
+ checked_fflush(f);
+ rewind(f);
+ string contents = checked_read(f);
+ checked_fclose(f);
+
+ EXPECT_STREQ("MODULE " MODULE_OS " " MODULE_ARCH " "
+ MODULE_ID " " MODULE_NAME "\n"
+ "PUBLIC aaaa 0 _xyz\n"
+ "PUBLIC ffff 0 _abc\n",
+ contents.c_str());
+}
+
+// Externs with the same address should only keep the first entry
+// added.
+TEST(Construct, DuplicateExterns) {
+ FILE *f = checked_tmpfile();
+ Module m(MODULE_NAME, MODULE_OS, MODULE_ARCH, MODULE_ID);
+
+ // Two externs.
+ Module::Extern *extern1 = new(Module::Extern);
+ extern1->address = 0xffff;
+ extern1->name = "_xyz";
+ Module::Extern *extern2 = new(Module::Extern);
+ extern2->address = 0xffff;
+ extern2->name = "_abc";
+
+ m.AddExtern(extern1);
+ m.AddExtern(extern2);
+
+ m.Write(f);
+ checked_fflush(f);
+ rewind(f);
+ string contents = checked_read(f);
+ checked_fclose(f);
+
+ EXPECT_STREQ("MODULE " MODULE_OS " " MODULE_ARCH " "
+ MODULE_ID " " MODULE_NAME "\n"
+ "PUBLIC ffff 0 _xyz\n",
+ contents.c_str());
+}