@@ -1252,39 +1252,30 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
1252
1252
CsectAuxRef.getSymbolType () == XCOFF::XTY_ER)
1253
1253
return false ;
1254
1254
1255
- // If the next symbol is a XTY_LD type symbol with same address, this XTY_SD
1255
+ // If the next symbol is an XTY_LD type symbol with same address, this XTY_SD
1256
1256
// symbol is not a function. Otherwise this is a function symbol for
1257
1257
// -ffunction-sections.
1258
1258
if (CsectAuxRef.getSymbolType () == XCOFF::XTY_SD) {
1259
1259
// If this is a csect with size 0, it won't be a function definition.
1260
1260
// This is used to hack situation that llvm always generates below symbol
1261
1261
// for -ffunction-sections:
1262
+ // FIXME: remove or replace this meaningless symbol.
1262
1263
// m 0x00000000 .text 1 unamex **No Symbol**
1263
1264
// a4 0x00000000 0 0 SD PR 0 0
1264
1265
if (getSize () == 0 )
1265
1266
return false ;
1266
1267
1267
- uint8_t NumberOfAuxEntries = getNumberOfAuxEntries ();
1268
-
1269
- // If this is the last main symbol table entry, there won't be XTY_LD type
1270
- // symbol below.
1271
- if (getEntryAddress () == getObject ()->getSymbolEntryAddressByIndex (
1272
- getObject ()->getNumberOfSymbolTableEntries () -
1273
- NumberOfAuxEntries - 1 ))
1274
- return true ;
1275
-
1276
- DataRefImpl Ref;
1277
- Ref.p = XCOFFObjectFile::getAdvancedSymbolEntryAddress (
1278
- getEntryAddress (), NumberOfAuxEntries + 1 );
1279
- XCOFFSymbolRef NextSym = getObject ()->toSymbolRef (Ref);
1280
- if (!NextSym.isCsectSymbol ())
1268
+ xcoff_symbol_iterator NextIt (this );
1269
+ // If this is the last main symbol table entry, there won't be an XTY_LD
1270
+ // type symbol below.
1271
+ if (++NextIt == getObject ()->symbol_end ())
1281
1272
return true ;
1282
1273
1283
- if (cantFail (getAddress ()) != cantFail (NextSym. getAddress ()))
1274
+ if (cantFail (getAddress ()) != cantFail (NextIt-> getAddress ()))
1284
1275
return true ;
1285
1276
1286
1277
// Check next symbol is XTY_LD. If so, this symbol is not a function.
1287
- Expected<XCOFFCsectAuxRef> NextCsectAuxEnt = NextSym. getXCOFFCsectAuxRef ();
1278
+ Expected<XCOFFCsectAuxRef> NextCsectAuxEnt = NextIt-> getXCOFFCsectAuxRef ();
1288
1279
if (!NextCsectAuxEnt) {
1289
1280
// If the next symbol has no aux entries, won't be a XTY_LD symbol.
1290
1281
consumeError (NextCsectAuxEnt.takeError ());
@@ -1300,12 +1291,7 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
1300
1291
if (CsectAuxRef.getSymbolType () == XCOFF::XTY_LD)
1301
1292
return true ;
1302
1293
1303
- const int16_t SectNum = getSectionNumber ();
1304
- Expected<DataRefImpl> SI = getObject ()->getSectionByNum (SectNum);
1305
- if (!SI)
1306
- return SI.takeError ();
1307
-
1308
- return (getObject ()->getSectionFlags (SI.get ()) & XCOFF::STYP_TEXT);
1294
+ return false ;
1309
1295
}
1310
1296
1311
1297
bool XCOFFSymbolRef::isCsectSymbol () const {
0 commit comments