@@ -126,6 +126,10 @@ impl<'a> Object<'a> {
126
126
let address = sym. address ( ) ;
127
127
let size = Self :: get_concrete_size ( & file, & sym) ;
128
128
if name == ".text" || name == ".data" {
129
+ // We don't want to include ".text" and ".data" symbols.
130
+ // If they are included, since their ranges cover other
131
+ // symbols, when searching a symbol for a given address,
132
+ // ".text" or ".data" is returned. That's not what we expect.
129
133
None
130
134
} else {
131
135
Some ( ParsedSym {
@@ -145,16 +149,19 @@ impl<'a> Object<'a> {
145
149
}
146
150
147
151
pub fn search_symtab < ' b > ( & ' b self , addr : u64 ) -> Option < & ' b [ u8 ] > {
152
+ // Symbols, except ".text" and ".data", are sorted and are not overlapped each other,
153
+ // so we can just perform a binary search here.
148
154
let i = match self . syms . binary_search_by_key ( & addr, |sym| sym. address ) {
149
155
Ok ( i) => i,
150
156
Err ( i) => i. checked_sub ( 1 ) ?,
151
157
} ;
152
158
let sym = self . syms . get ( i) ?;
153
159
if ( sym. address ..sym. address + sym. size ) . contains ( & addr) {
154
- // FIXME: Should we trim the leading '.' of
155
- // the symbol of a function entry?
156
- // If not, the rust mangler might not work properly.
157
- // Or we should update rust mangler to trim the leading '.'?
160
+ // On AIX, for a function call, for example, `foo()`, we have
161
+ // two symbols `foo` and `.foo`. `foo` references the function
162
+ // descriptor and `.foo` references the function entry. We trim
163
+ // the prefix `.` here, so that the rust demangler can work
164
+ // properly.
158
165
Some ( sym. name . trim_start_matches ( "." ) . as_bytes ( ) )
159
166
} else {
160
167
None
0 commit comments