aboutsummaryrefslogtreecommitdiff
path: root/src/common/module.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.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.cc')
-rw-r--r--src/common/module.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/common/module.cc b/src/common/module.cc
index c980b96f..0c36516a 100644
--- a/src/common/module.cc
+++ b/src/common/module.cc
@@ -55,6 +55,9 @@ Module::~Module() {
for (vector<StackFrameEntry *>::iterator it = stack_frame_entries_.begin();
it != stack_frame_entries_.end(); it++)
delete *it;
+ for (ExternSet::iterator it = externs_.begin();
+ it != externs_.end(); it++)
+ delete *it;
}
void Module::SetLoadAddress(Address address) {
@@ -64,7 +67,8 @@ void Module::SetLoadAddress(Address address) {
void Module::AddFunction(Function *function) {
std::pair<FunctionSet::iterator,bool> ret = functions_.insert(function);
if (!ret.second) {
- // Free the duplicate we failed to insert because we own it.
+ // Free the duplicate that was not inserted because this Module
+ // now owns it.
delete function;
}
}
@@ -79,11 +83,25 @@ void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) {
stack_frame_entries_.push_back(stack_frame_entry);
}
+void Module::AddExtern(Extern *ext) {
+ std::pair<ExternSet::iterator,bool> ret = externs_.insert(ext);
+ if (!ret.second) {
+ // Free the duplicate that was not inserted because this Module
+ // now owns it.
+ delete ext;
+ }
+}
+
void Module::GetFunctions(vector<Function *> *vec,
vector<Function *>::iterator i) {
vec->insert(i, functions_.begin(), functions_.end());
}
+void Module::GetExterns(vector<Extern *> *vec,
+ vector<Extern *>::iterator i) {
+ vec->insert(i, externs_.begin(), externs_.end());
+}
+
Module::File *Module::FindFile(const string &name) {
// A tricky bit here. The key of each map entry needs to be a
// pointer to the entry's File's name string. This means that we
@@ -211,6 +229,16 @@ bool Module::Write(FILE *stream) {
return ReportError();
}
+ // Write out 'PUBLIC' records.
+ for (ExternSet::const_iterator extern_it = externs_.begin();
+ extern_it != externs_.end(); extern_it++) {
+ Extern *ext = *extern_it;
+ if (0 > fprintf(stream, "PUBLIC %llx 0 %s\n",
+ (unsigned long long) (ext->address - load_address_),
+ ext->name.c_str()))
+ return ReportError();
+ }
+
// Write out 'STACK CFI INIT' and 'STACK CFI' records.
vector<StackFrameEntry *>::const_iterator frame_it;
for (frame_it = stack_frame_entries_.begin();