@@ -550,7 +550,7 @@ class MachObjectWriter : public MCObjectWriter {
550
550
// Add the local offset, if needed.
551
551
if (Base != &SD)
552
552
Value += Layout.getSymbolOffset (&SD) - Layout.getSymbolOffset (Base);
553
- } else if (Symbol->isInSection ()) {
553
+ } else if (Symbol->isInSection () && !Symbol-> isVariable () ) {
554
554
// The index is the section ordinal (1-based).
555
555
Index = SD.getFragment ()->getParent ()->getOrdinal () + 1 ;
556
556
IsExtern = 0 ;
@@ -1028,17 +1028,17 @@ class MachObjectWriter : public MCObjectWriter {
1028
1028
// FIXME!
1029
1029
report_fatal_error (" FIXME: relocations to absolute targets "
1030
1030
" not yet implemented" );
1031
- } else if (SD->getSymbol ().isVariable ()) {
1032
- int64_t Res;
1033
- if (SD->getSymbol ().getVariableValue ()->EvaluateAsAbsolute (
1034
- Res, Layout, SectionAddress)) {
1035
- FixedValue = Res;
1036
- return ;
1031
+ } else {
1032
+ // Resolve constant variables.
1033
+ if (SD->getSymbol ().isVariable ()) {
1034
+ int64_t Res;
1035
+ if (SD->getSymbol ().getVariableValue ()->EvaluateAsAbsolute (
1036
+ Res, Layout, SectionAddress)) {
1037
+ FixedValue = Res;
1038
+ return ;
1039
+ }
1037
1040
}
1038
1041
1039
- report_fatal_error (" unsupported relocation of variable '" +
1040
- SD->getSymbol ().getName () + " '" );
1041
- } else {
1042
1042
// Check whether we need an external or internal relocation.
1043
1043
if (doesSymbolRequireExternRelocation (SD)) {
1044
1044
IsExtern = 1 ;
@@ -1129,17 +1129,17 @@ class MachObjectWriter : public MCObjectWriter {
1129
1129
// FIXME: Currently, these are never generated (see code below). I cannot
1130
1130
// find a case where they are actually emitted.
1131
1131
Type = macho::RIT_Vanilla;
1132
- } else if (SD->getSymbol ().isVariable ()) {
1133
- int64_t Res;
1134
- if (SD->getSymbol ().getVariableValue ()->EvaluateAsAbsolute (
1135
- Res, Layout, SectionAddress)) {
1136
- FixedValue = Res;
1137
- return ;
1132
+ } else {
1133
+ // Resolve constant variables.
1134
+ if (SD->getSymbol ().isVariable ()) {
1135
+ int64_t Res;
1136
+ if (SD->getSymbol ().getVariableValue ()->EvaluateAsAbsolute (
1137
+ Res, Layout, SectionAddress)) {
1138
+ FixedValue = Res;
1139
+ return ;
1140
+ }
1138
1141
}
1139
1142
1140
- report_fatal_error (" unsupported relocation of variable '" +
1141
- SD->getSymbol ().getName () + " '" );
1142
- } else {
1143
1143
// Check whether we need an external or internal relocation.
1144
1144
if (doesSymbolRequireExternRelocation (SD)) {
1145
1145
IsExtern = 1 ;
0 commit comments