@@ -205,31 +205,39 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
205
205
llvm::object::XCOFFSymbolRef xcoff_sym_ref (symbol_ref);
206
206
llvm::Expected<llvm::StringRef> name_or_err = xcoff_sym_ref.getName ();
207
207
if (!name_or_err) {
208
- consumeError (name_or_err.takeError ());
208
+ LLDB_LOG_ERROR (log, name_or_err.takeError (),
209
+ " Unable to extract name from the xcoff symbol ref object" );
209
210
continue ;
210
211
}
211
212
llvm::StringRef symbolName = name_or_err.get ();
212
- // Remove the dot prefix for demangle
213
- llvm::StringRef symbol_name =
213
+ // Remove the dot prefix from symbol names.
214
+ llvm::StringRef name_no_dot =
214
215
symbolName.starts_with (" ." ) ? symbolName.drop_front () : symbolName;
215
216
auto storageClass = xcoff_sym_ref.getStorageClass ();
217
+ // If its the hidden ext TOC symbol, add it directly,
218
+ // for all other C_HIDEXT symbols, proceed to other checks.
216
219
if (storageClass == XCOFF::C_HIDEXT && symbolName != " TOC" ) {
220
+ // We do not need to add entries with 0 or >1 auxiliary data
217
221
if (xcoff_sym_ref.getNumberOfAuxEntries () != 1 )
218
222
continue ;
219
223
auto aux_csect_or_err = xcoff_sym_ref.getXCOFFCsectAuxRef ();
220
224
if (!aux_csect_or_err) {
221
- consumeError (aux_csect_or_err.takeError ());
225
+ LLDB_LOG_ERROR (log, aux_csect_or_err.takeError (),
226
+ " Unable to access xcoff csect aux ref object" );
222
227
continue ;
223
228
}
224
229
const llvm::object::XCOFFCsectAuxRef csect_aux = aux_csect_or_err.get ();
225
- if (csect_aux.getStorageMappingClass () != XCOFF::XMC_PR ||
226
- (m_binary->is64Bit () ? (csect_aux.getAuxType64 () != XCOFF::AUX_CSECT)
227
- : false ))
230
+ // Only add hidden ext entries which come under Program Code, skip others
231
+ if (csect_aux.getStorageMappingClass () != XCOFF::XMC_PR)
232
+ continue ;
233
+ // This does not apply to 32-bit,
234
+ // Only add csect symbols identified by the aux entry, skip others
235
+ if (m_binary->is64Bit () ? (csect_aux.getAuxType64 () != XCOFF::AUX_CSECT))
228
236
continue ;
229
237
}
230
238
231
239
Symbol symbol;
232
- symbol.GetMangled ().SetValue (ConstString (symbol_name ));
240
+ symbol.GetMangled ().SetValue (ConstString (name_no_dot ));
233
241
234
242
int16_t sectionNumber = xcoff_sym_ref.getSectionNumber ();
235
243
size_t sectionIndex = static_cast <size_t >(sectionNumber - 1 );
@@ -248,7 +256,8 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
248
256
Expected<llvm::object::SymbolRef::Type> sym_type_or_err =
249
257
symbol_ref.getType ();
250
258
if (!sym_type_or_err) {
251
- consumeError (sym_type_or_err.takeError ());
259
+ LLDB_LOG_ERROR (log, aux_csect_or_err.takeError (),
260
+ " Unable to access xcoff symbol type" );
252
261
continue ;
253
262
}
254
263
symbol.SetType (MapSymbolType (sym_type_or_err.get ()));
0 commit comments