Skip to content

Commit 47070d8

Browse files
author
Chen Zheng
committed
address comments
1 parent 6fe33ae commit 47070d8

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

llvm/include/llvm/Object/XCOFFObjectFile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,9 @@ class xcoff_symbol_iterator : public symbol_iterator {
853853
xcoff_symbol_iterator(const basic_symbol_iterator &B)
854854
: symbol_iterator(B) {}
855855

856+
xcoff_symbol_iterator(const XCOFFSymbolRef *Symbol)
857+
: symbol_iterator(*Symbol) {}
858+
856859
const XCOFFSymbolRef *operator->() const {
857860
return static_cast<const XCOFFSymbolRef *>(symbol_iterator::operator->());
858861
}

llvm/lib/Object/XCOFFObjectFile.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,39 +1252,30 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
12521252
CsectAuxRef.getSymbolType() == XCOFF::XTY_ER)
12531253
return false;
12541254

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
12561256
// symbol is not a function. Otherwise this is a function symbol for
12571257
// -ffunction-sections.
12581258
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_SD) {
12591259
// If this is a csect with size 0, it won't be a function definition.
12601260
// This is used to hack situation that llvm always generates below symbol
12611261
// for -ffunction-sections:
1262+
// FIXME: remove or replace this meaningless symbol.
12621263
// m 0x00000000 .text 1 unamex **No Symbol**
12631264
// a4 0x00000000 0 0 SD PR 0 0
12641265
if (getSize() == 0)
12651266
return false;
12661267

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())
12811272
return true;
12821273

1283-
if (cantFail(getAddress()) != cantFail(NextSym.getAddress()))
1274+
if (cantFail(getAddress()) != cantFail(NextIt->getAddress()))
12841275
return true;
12851276

12861277
// 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();
12881279
if (!NextCsectAuxEnt) {
12891280
// If the next symbol has no aux entries, won't be a XTY_LD symbol.
12901281
consumeError(NextCsectAuxEnt.takeError());
@@ -1300,12 +1291,7 @@ Expected<bool> XCOFFSymbolRef::isFunction() const {
13001291
if (CsectAuxRef.getSymbolType() == XCOFF::XTY_LD)
13011292
return true;
13021293

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;
13091295
}
13101296

13111297
bool XCOFFSymbolRef::isCsectSymbol() const {

0 commit comments

Comments
 (0)