Skip to content

Commit b9c2b6c

Browse files
committed
MC/Mach-O: Find section ordinal's by looking at the symbol, instead of assuming they are present in a fragment.
llvm-svn: 130519
1 parent 124ae13 commit b9c2b6c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,10 @@ class MachObjectWriter : public MCObjectWriter {
10501050
FixedValue -= Layout.getSymbolOffset(SD);
10511051
} else {
10521052
// The index is the section ordinal (1-based).
1053-
Index = SD->getFragment()->getParent()->getOrdinal() + 1;
1054-
FixedValue += getSectionAddress(SD->getFragment()->getParent());
1053+
const MCSectionData &SymSD = Asm.getSectionData(
1054+
SD->getSymbol().getSection());
1055+
Index = SymSD.getOrdinal() + 1;
1056+
FixedValue += getSectionAddress(&SymSD);
10551057
}
10561058
if (IsPCRel)
10571059
FixedValue -= getSectionAddress(Fragment->getParent());
@@ -1149,8 +1151,10 @@ class MachObjectWriter : public MCObjectWriter {
11491151
FixedValue -= Layout.getSymbolOffset(SD);
11501152
} else {
11511153
// The index is the section ordinal (1-based).
1152-
Index = SD->getFragment()->getParent()->getOrdinal() + 1;
1153-
FixedValue += getSectionAddress(SD->getFragment()->getParent());
1154+
const MCSectionData &SymSD = Asm.getSectionData(
1155+
SD->getSymbol().getSection());
1156+
Index = SymSD.getOrdinal() + 1;
1157+
FixedValue += getSectionAddress(&SymSD);
11541158
}
11551159
if (IsPCRel)
11561160
FixedValue -= getSectionAddress(Fragment->getParent());

0 commit comments

Comments
 (0)