Skip to content

Commit d92b368

Browse files
committed
[MachO] Fix incorrect handling of BIND_SPECIAL_DYLIB_*_LOOKUP in chained fixups
These lookup modes are negative values that are encoded in the library ordinal, an unsigned field, of an import fixup entry. Incorrect sign extension when converting these ordinals back to signed values led to them being misinterpreted.
1 parent 30cb296 commit d92b368

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

view/macho/chained_fixups.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ ImportEntry ReadChainedImport32(BinaryReader& reader, std::span<const char> symb
247247
return {
248248
std::string_view(&symbolData[import.name_offset]),
249249
0,
250-
static_cast<int32_t>(import.lib_ordinal),
250+
static_cast<int8_t>(import.lib_ordinal),
251251
(bool)import.weak_import,
252252
};
253253
}
@@ -259,7 +259,7 @@ ImportEntry ReadChainedImportAddend32(BinaryReader& reader, std::span<const char
259259
return {
260260
std::string_view(&symbolData[import.name_offset]),
261261
static_cast<uint32_t>(import.addend),
262-
static_cast<int32_t>(import.lib_ordinal),
262+
static_cast<int8_t>(import.lib_ordinal),
263263
(bool)import.weak_import,
264264
};
265265
}
@@ -271,7 +271,7 @@ ImportEntry ReadChainedImportAddend64(BinaryReader& reader, std::span<const char
271271
return {
272272
std::string_view(&symbolData[import.name_offset]),
273273
import.addend,
274-
static_cast<int32_t>(import.lib_ordinal),
274+
static_cast<int16_t>(import.lib_ordinal),
275275
(bool)import.weak_import,
276276
};
277277
}

0 commit comments

Comments
 (0)