@@ -126,6 +126,10 @@ impl<'a> Object<'a> {
126126 let address = sym. address ( ) ;
127127 let size = Self :: get_concrete_size ( & file, & sym) ;
128128 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.
129133 None
130134 } else {
131135 Some ( ParsedSym {
@@ -145,16 +149,19 @@ impl<'a> Object<'a> {
145149 }
146150
147151 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.
148154 let i = match self . syms . binary_search_by_key ( & addr, |sym| sym. address ) {
149155 Ok ( i) => i,
150156 Err ( i) => i. checked_sub ( 1 ) ?,
151157 } ;
152158 let sym = self . syms . get ( i) ?;
153159 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.
158165 Some ( sym. name . trim_start_matches ( "." ) . as_bytes ( ) )
159166 } else {
160167 None
0 commit comments