Skip to content

Commit 4d63189

Browse files
Addressed comments
1 parent 21f5a39 commit 4d63189

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,31 +205,39 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
205205
llvm::object::XCOFFSymbolRef xcoff_sym_ref(symbol_ref);
206206
llvm::Expected<llvm::StringRef> name_or_err = xcoff_sym_ref.getName();
207207
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");
209210
continue;
210211
}
211212
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 =
214215
symbolName.starts_with(".") ? symbolName.drop_front() : symbolName;
215216
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.
216219
if (storageClass == XCOFF::C_HIDEXT && symbolName != "TOC") {
220+
// We do not need to add entries with 0 or >1 auxiliary data
217221
if (xcoff_sym_ref.getNumberOfAuxEntries() != 1)
218222
continue;
219223
auto aux_csect_or_err = xcoff_sym_ref.getXCOFFCsectAuxRef();
220224
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");
222227
continue;
223228
}
224229
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))
228236
continue;
229237
}
230238

231239
Symbol symbol;
232-
symbol.GetMangled().SetValue(ConstString(symbol_name));
240+
symbol.GetMangled().SetValue(ConstString(name_no_dot));
233241

234242
int16_t sectionNumber = xcoff_sym_ref.getSectionNumber();
235243
size_t sectionIndex = static_cast<size_t>(sectionNumber - 1);
@@ -248,7 +256,8 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {
248256
Expected<llvm::object::SymbolRef::Type> sym_type_or_err =
249257
symbol_ref.getType();
250258
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");
252261
continue;
253262
}
254263
symbol.SetType(MapSymbolType(sym_type_or_err.get()));

0 commit comments

Comments
 (0)