113 Commits

Author SHA1 Message Date
Marvin Häuser
164696d1dc OcMachoLib: Resolve indirect symbol ambiguity
Mach-O uses "indirect symbol" ambiguously. The first kind are "indirect
symbols" indicated by their type. They are located in the regular symbol
table, possibly outside the local, external and undefined ranges. Their
value is an index into the string table, which indicates the name of
another symbol they alias. We assume these to only be used by KPIs,
mostly as symbol aliases for deprecated symbol names.

The second kind is the "indirect symbol table", which is merely a flat
list of 32-bit indices into the symbol table.

When the handling code was written, the incorrect assumption was made
that the "indirect symbol table" is a range of "indirect symbols", much
like how local, external and undefined symbols are explicitly indexed.
However, this is not true and causes bugs in handling indirect symbols.

This patch drops this incorrect (and dangerous) assumption and strictly
separates the two concepts. As OpenCore does not inject KPIs, ignore
indirect symbols entirely.
2025-06-12 12:13:55 +02:00
Savva Mitrofanov
b2d438d6f3 Switch OcGuardLib to BaseOverflowLib 2023-04-13 13:16:14 +06:00
Marvin Häuser
d916dd65b8 OcMachoLib: Treat container Mach-O as reference file
As of macOS 13 Developer Beta 3, the Kernel Collection's inner kernel
references a segment that precedes itself. The current model is that
a Kernel Collection is a container format and the included files are
(mostly) separate. Hence, this was treated as an out-of-bounds issue.
Kernel Collections apparently are rather an unconventional composite
format, where the sub-files are still part of the whole. Redesign
OcMachoLib to treat the Kernel Collection as the reference file.
Patches still use only the inner file, while parsing considers the
whole file.
2022-07-07 17:52:25 +02:00
PMheart
228f8ca1fb Codestyle: Apply codestyle changes with Uncrustify 2022-04-25 14:51:15 +02:00
Goldfish64
0c99e037f5 OcMachoLib: Fix improper file offset cast in MachoExpandImage 2020-10-18 13:17:25 -05:00
John Davis
676ef93d9d
OcAppleKernelLib: Add 32-bit prelinking support (#122) 2020-09-29 12:41:37 +03:00
John Davis
74062d4e0f
OcAppleKernelLib: Add 32-bit Mach-O and patching support (#118) 2020-09-13 22:57:10 +03:00
vit9696
c3e14b6824
OcAppleKernelLib: Implement mkext injection support (#99) 2020-08-15 00:40:06 +03:00
vit9696
0b3dcf4f7e OcAppleKernelLib: Improve handling of KC DySymtab 2020-07-04 20:21:37 +03:00
Download-Fritz
07b697d28d OcMachoLib: Support KC Mach-Os 2020-07-04 15:28:22 +02:00
vit9696
0271bacc27 OcAppleKernelLib: More progress with 11.0, many thx to @Download-Fritz 2020-07-04 01:58:04 +03:00
Download-Fritz
275c78bbd7 OcMachoLib: Add API to externally retrieve symbols 2020-06-29 20:28:23 +02:00
Download-Fritz
5d0b9f4832 OcMachoLib: Remove redundant alignment checks 2020-06-29 19:31:36 +02:00
vit9696
83b77fff56 OcMachoLib: Fix MSVC warning 2020-06-28 19:18:47 +03:00
Download-Fritz
0ad48de5b4 OcMachoLib: Make the LC retrieval API public 2020-06-28 17:47:19 +02:00
vit9696
de272bf210 OcMachoLib: Fix KC init and segment merging 2020-06-28 12:01:54 +03:00
vit9696
ebdc3fa056 OcAppleKernelLib: Start building new Mach-O functions 2020-06-27 20:55:16 +03:00
vit9696
e6bec3ae80 Debug: Fix some log tags 2020-05-17 16:53:02 +03:00
vit9696
4421b5a758 OcBootManagementLib: Debug restyle 2019-11-04 18:51:48 +03:00
Download-Fritz
156cb7c586 Various type and cast fixes 2019-11-02 23:16:33 +01:00
Download-Fritz
6c882e1cbc OcMachoLib/OcAppleKernelLib: Support Kernel Resource KEXTs 2019-09-07 17:28:36 +02:00
Download-Fritz
4917e8d73e OcGuardLib: Introduce OC_ALIGNOF and deprecate OC_ALIGNED 2019-08-28 15:37:55 +02:00
vit9696
e011d9030f OcMachoLib: Implement MachoRuntimeGetEntryAddress 2019-04-30 22:08:08 +03:00
Download-Fritz
4203232842 OcMachoLib: Do not ASSERT on Section->SegmentName mismatch. 2019-04-05 13:30:25 +02:00
vit9696
dfe7f8f5d4 analysis: Fix warnings 2019-04-03 06:37:38 +03:00
Download-Fritz
e17d99deb4 OcMachoLib: Fail when image is to be dynamically linked and lacks DySymtab. 2019-03-29 12:43:45 +01:00
Download-Fritz
826d078efd OcMachoLib and OcAppleMachoLib: Silence type warnings. 2019-03-29 10:38:42 +01:00
vit9696
f0268b6ed3 OcMachoLib: Fix expansion of images with segment size mismatch before last 2019-03-28 22:56:51 +03:00
vit9696
737e17c847 OcMachoLib: Implement support for unpacking FAT images 2019-03-27 19:36:25 +03:00
vit9696
2c84d36d84 OcAppleKernelLib: Fix inaccurate bounds checking in Mach-O expansion 2019-03-25 01:38:14 +03:00
Download-Fritz
f760c0ca74 OcMachoLib and OcAppleKernelLib: Silence warnings. 2019-03-24 13:17:29 +01:00
vit9696
2a72e67ac0 Move command stripping to Mach-O lib 2019-03-24 11:52:10 +03:00
vit9696
e169a7aa7e Ensure 1:1 disk:vm mach-o matching requirement during kext inject 2019-03-24 01:50:57 +03:00
Download-Fritz
8454cdd574 OcAppleKernelLib: Retrieve Relocation target via GetPointerByAddress API. 2019-03-23 21:03:54 +01:00
Download-Fritz
25616b2e21 OcMachoLib: Check Section bounds against Segment. 2019-03-23 20:26:22 +01:00
vit9696
72b4e55786 Fix invalid Mach-O command handling during kext injection 2019-03-23 17:17:33 +03:00
vit9696
868c064fb1 Get symbol location work 2019-03-23 15:05:12 +03:00
vit9696
30fb879941 Add internal symbol table stubs 2019-03-20 16:07:18 +03:00
vit9696
59f86290b6 Add missing Mach-O dependencies 2019-03-19 23:16:17 +03:00
vit9696
27eb6080ba Start refactoring SMBIOS 2019-03-01 20:07:50 +03:00
vit9696
c1ef04e47c Fix OcMachoLib compilation 2019-01-17 12:34:26 +03:00
vit9696
caabf0b2ab Continue fixing and refactoring OcMachoLib 2019-01-16 17:46:10 +03:00
vit9696
aca4a620ac Fix sanity of symbol retrieval code 2019-01-16 13:15:22 +03:00
vit9696
69f441b5ec Restore OcMachoLib interfaces for convenience resons 2019-01-15 23:34:01 +03:00
Download-Fritz
28c65c9e9e OcMachoLib: Add forgotten initialization of Context->SymbolTable. 2019-01-15 19:14:10 +01:00
vit9696
a43cb1386e Start cleaning up OcMachoLib 2019-01-15 18:23:29 +03:00
Download-Fritz
793b78d103 OcMachoLib: Revise several function prorotypes and checks as part of security considerations. 2019-01-12 22:57:57 +01:00
Download-Fritz
fbac1c4258 OcMachoLib: Runtime-check whether the next LC is in bounds to allow "!= NULL" loops. 2019-01-05 16:29:48 +01:00
Download-Fritz
e92ab78bfc OcMachoLib: Add forgotten change. 2019-01-05 15:38:28 +01:00
Download-Fritz
dac925cd58 Runtime-check whether the next section is in bounds to allow "!= NULL" loops. 2019-01-05 15:37:46 +01:00