Skip to content

Commit b97b006

Browse files
author
Bar Soloveychik
committed
fixed comments
1 parent 315266d commit b97b006

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,10 +2041,11 @@ static char FindRISCVMappingSymbol(const char *symbol_name) {
20412041
if (!symbol_name)
20422042
return '\0';
20432043

2044-
if (symbol_name[0] == '$' &&
2045-
(symbol_name[1] == 'd' || symbol_name[1] == 'x') &&
2046-
symbol_name[2] == '\0') {
2047-
return symbol_name[1];
2044+
if (strcmp(symbol_name, "$d") == 0) {
2045+
return 'd';
2046+
}
2047+
if (strcmp(symbol_name, "$x") == 0) {
2048+
return 'x';
20482049
}
20492050
return '\0';
20502051
}
@@ -2117,8 +2118,8 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
21172118
// Skip local symbols starting with ".L" because these are compiler
21182119
// generated local labels used for internal purposes (e.g. debugging,
21192120
// optimization) and are not relevant for symbol resolution or external
2120-
// linkage in RISC-V binaries.
2121-
if (symbol_name[0] == '.' && symbol_name[1] == 'L')
2121+
// linkage.
2122+
if (llvm::StringRef(symbol_name).starts_with(".L"))
21222123
continue;
21232124
// No need to add non-section symbols that have no names
21242125
if (symbol.getType() != STT_SECTION &&
@@ -2208,9 +2209,8 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
22082209

22092210
int64_t symbol_value_offset = 0;
22102211
uint32_t additional_flags = 0;
2211-
llvm::Triple::ArchType arch_machine = arch.GetMachine();
22122212
if (arch.IsValid()) {
2213-
if (arch_machine == llvm::Triple::arm) {
2213+
if (arch.GetMachine() == llvm::Triple::arm) {
22142214
if (symbol.getBinding() == STB_LOCAL) {
22152215
char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
22162216
if (symbol_type == eSymbolTypeCode) {
@@ -2235,7 +2235,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
22352235
if (mapping_symbol)
22362236
continue;
22372237
}
2238-
} else if (arch_machine == llvm::Triple::aarch64) {
2238+
} else if (arch.GetMachine() == llvm::Triple::aarch64) {
22392239
if (symbol.getBinding() == STB_LOCAL) {
22402240
char mapping_symbol = FindArmAarch64MappingSymbol(symbol_name);
22412241
if (symbol_type == eSymbolTypeCode) {
@@ -2253,13 +2253,13 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
22532253
if (mapping_symbol)
22542254
continue;
22552255
}
2256-
} else if (arch_machine == llvm::Triple::riscv32 ||
2257-
arch_machine == llvm::Triple::riscv64 ||
2258-
arch_machine == llvm::Triple::riscv32be ||
2259-
arch_machine == llvm::Triple::riscv64be) {
2256+
} else if (arch.GetTriple().isRISCV()) {
22602257
if (symbol.getBinding() == STB_LOCAL) {
22612258
char mapping_symbol = FindRISCVMappingSymbol(symbol_name);
22622259
if (symbol_type == eSymbolTypeCode) {
2260+
// Only handle $d and $x mapping symbols.
2261+
// Other mapping symbols are ignored as they don't affect address
2262+
// classification.
22632263
switch (mapping_symbol) {
22642264
case 'x':
22652265
// $x - marks a RISCV instruction sequence
@@ -2276,7 +2276,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
22762276
}
22772277
}
22782278

2279-
if (arch_machine == llvm::Triple::arm) {
2279+
if (arch.GetMachine() == llvm::Triple::arm) {
22802280
if (symbol_type == eSymbolTypeCode) {
22812281
if (symbol.st_value & 1) {
22822282
// Subtracting 1 from the address effectively unsets the low order

0 commit comments

Comments
 (0)