#
…

2021-01-11

00:04aratuk has joined #asahi-re
00:09aratuk has quit [Ping timeout: 265 seconds]
01:39dibas has quit [Ping timeout: 260 seconds]
02:04klaus has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
02:28dibas has joined #asahi-re
02:28dibas has joined #asahi-re
03:50ransom has joined #asahi-re
03:52Tokamak has joined #asahi-re
04:05aratuk has joined #asahi-re
04:11aratuk has quit [Ping timeout: 264 seconds]
05:32ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
05:36Tokamak has quit [Remote host closed the connection]
05:45Tokamak has joined #asahi-re
06:40ransom has joined #asahi-re
06:41justMaku has quit [Remote host closed the connection]
06:41q3k|m has quit [Remote host closed the connection]
06:57ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
07:08Tokamak has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
07:40klaus_ has joined #asahi-re
08:07aratuk has joined #asahi-re
08:12aratuk has quit [Ping timeout: 264 seconds]
09:52marcan changed the topic of #asahi-re to: Asahi Linux: porting Linux to Apple Silicon macs | Hardware / boot process / firmware interface reverse engineering | WARNING: this channel (only) may contain binary reverse engineering discussion | RE policy: https://alx.sh/re (MANDATORY READ) | GitHub: https://alx.sh/g | Wiki: https://alx.sh/w | Logs: https://alx.sh/l/asahi-re
09:58bylaws has joined #asahi-re
10:03lewurm has joined #asahi-re
10:31rootspring[m] has joined #asahi-re
11:03DarthCloud has quit [Ping timeout: 240 seconds]
11:05DarthCloud has joined #asahi-re
12:09aratuk has joined #asahi-re
12:13aratuk has quit [Ping timeout: 265 seconds]
13:34dstzd has quit [Quit: ZNC - https://znc.in]
13:35dstzd has joined #asahi-re
13:40mogery has joined #asahi-re
14:00aratuk has joined #asahi-re
14:05aratuk has quit [Ping timeout: 272 seconds]
14:07justMaku has joined #asahi-re
14:14robher has joined #asahi-re
14:19q3k|m has joined #asahi-re
14:22justMaku has quit [Quit: Client limit exceeded: 150]
14:24dstzd has quit [Quit: ZNC - https://znc.in]
14:24dstzd has joined #asahi-re
15:06sumoon[m] has joined #asahi-re
15:19klaus_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
15:30HeN has quit [Quit: Connection closed for inactivity]
15:34Tokamak has joined #asahi-re
15:58klaus_ has joined #asahi-re
16:01aratuk has joined #asahi-re
16:06aratuk has quit [Ping timeout: 264 seconds]
16:10ransom has joined #asahi-re
16:25ransom_ has joined #asahi-re
16:29ransom has quit [Ping timeout: 272 seconds]
16:30davidrysk[m]marcan: https://twitter.com/marcan42/status/1348668349404782592 -- are you looking at the built t8101 kernel?
16:31marcandavidrysk[m]: just the mach-o structures, to see what I should be feeding iBoot
16:31marcan(not the code)
16:33marcanI'm probably do a trick I've used in the past, of building the mach-o structures inside the memory image in a linker script
16:33marcanthen I can just build with a normal ELF tolchain and objcopy -O binary to get a mach-o
16:37davidrysk[m]wonders if PongoOS has done some of this work already
16:39davidrysk[m]oop, PongoOS directly includes APSL-licensed Apple headers :(
16:44Shizmach-O ain't fun
16:46marcanthere's a reason I'm staying away from PongoOS
16:46marcandifferent standards
16:46marcan(and why I added that warning to our RE policy)
16:54davidrysk[m]that's not how a typical (userspace) mach-o encodes its entry point
16:55JTLdavidrysk[m]: I've never studied Mach-O, tell me more :p
16:55davidrysk[m]no, it uses LC_MAIN
16:55ransom has joined #asahi-re
16:55davidrysk[m]uh I know corkami made a poster for mach-o
16:55marcanoh that would've been helpful about 3 hours ago
16:56davidrysk[m]too basic :)
16:56marcanhttps://mrcn.st/p/5SrEyT0o some subset of mach-o parsed with Construct
16:56davidrysk[m]marcan: are you looking at the kernel or the kernelcollection?
16:56marcan/usr/bin/header lol, where did that come from
16:57marcanI must be tired already
16:57marcandavidrysk[m]: kernelcache is what it is called
16:57davidrysk[m](about you being tired lol)
16:57modwizcode has joined #asahi-re
16:57ransom_ has quit [Ping timeout: 256 seconds]
16:57davidrysk[m]the manpage for kmutil uses the term "boot kext collection"
16:58marcanyeah, I guess that's a better name for it
16:58marcananyway, it's just a mach-o
16:58davidrysk[m]but isn't clear whether that's just for kexts
16:58marcanthey prelink all the boot kexts into a single kernel
16:59davidrysk[m]my point though: kmutil is probably what wraps it into an asn.1
16:59davidrysk[m]the mach-of file for the kernel is at /System/Library/Kernels and doesn't look wrapped in an asn.1 to me
17:00marcanyes, kmutil does the asn.1 bit
17:01davidrysk[m]question I have: will iBoot load a mach-o that has an LC_MAIN pointing to the entry point?
17:01marcanunlikely, if that's not how XNU loads
17:01davidrysk[m]without the configure-boot option in kmutil we can't test :)
17:01Shizdavidrysk[m]: kmutil also uses kernelcache at other points iirc
17:02davidrysk[m]Shiz: yes, but does it use kernelcache for configure-boot --custom-boot-object? the documentation for that specifically states that you use that to load a mach-o
17:03mogeryy has joined #asahi-re
17:03Shizidk, but bputil's policy stuff seems to refer to it as kcOS :p
17:03Shizkc being... kernelcache
17:03Shiz(presumably)
17:04mogery has quit [Ping timeout: 260 seconds]
17:04Shizmarcan: fwiw, libkern/kxld/kxld_object.c in xnu sources may be relevant
17:05marcandavidrysk[m]: a kernelcache *is* a mach-o (wrapped in an img4)
17:07Shizgobjdump: kc: unknown load command 0x34
17:07Shizooh :)
17:09Shizah, LC_DYLD_CHAINED_FIXUPS
17:10modwizcodeWhy is it wrapped in an img4?
17:11davidrysk[m]mach-o support in objdump is incomplete, otool (from apple's cctools) is more complete
17:13Shiz davidrysk[m] otool doesn't even recognize it as an object file :)
17:13davidrysk[m]Shiz: the img4?
17:13davidrysk[m](which file?)
17:13Shizmight be my local macOS version which is outdated
17:14Shizthe kernelcache extracted from the img4, trying on m1 now
17:14Shizanyway
17:14Shizapparently this can dump kernelcaches
17:15davidrysk[m]that looks handy (just note that his tools are proprietary licensed)
17:15davidrysk[m](usually are **)
17:15Shizno source sadly
17:16Shizdoesn't matter anyway, because it segfaults on the kernel :)
17:17Shizit doesn't like LC_FILESET_ENTRY (0x35)
17:21davidrysk[m]my otool is fine with that
17:21davidrysk[m]probably is that your local macOS (or your Xcode) is outdated
17:21Shizprobably yea
17:22davidrysk[m](latest Xcode works with macOS 10.15.x fwiw)
17:23Shizoh yay, mach-o filesets
17:29jixdavidrysk[m]: LC_UNIXTHREAD is older than LC_MAIN and was also used for userspace stuff before
17:35jixI haven't touched osx stuff in over 10 years, but I back then I did some sizecoding and that involved sticking some code into the LC_UNIXTHREAD command so that all those bytes aren't wasted
17:38Shizsounds familiar
17:42davidrysk[m]well, will iBoot boot a simpler Mach-O that doesn't have all this crap?
17:51HeN has joined #asahi-re
18:02aratuk has joined #asahi-re
18:06aratuk has quit [Ping timeout: 256 seconds]
18:15tiagom has joined #asahi-re
18:19Shizmarcan: did you extract the kernel from the fileset? :p
18:25marcanShiz: fileset?
18:25Shizyeah, the kernelcache is a fileset
18:25Shizit's just a container with a bunch of inner mach-Os
18:25Shizspecial type of mach-O file
18:25marcannot quite
18:25marcanit used to be that
18:25marcanthese days it's all prelinked anyway
18:25Shizi just extracted the kernelcache
18:25marcanthere's one big massive text section outside the fileset
18:26Shizand it has a com.apple.kernel, which is a mach-o executable
18:26marcananyway none of this matters as far as the bootloader is concerned
18:27Shiz-rw-r--r-- 1 partynorge staff 85M 11 Jan 19:24 com.apple.kernel
18:27Shizthe sizes all add up to me, i think it's inside the fileset
18:28Shizyeah, this is not prelinked
18:29marcanwhat file are you looking at?
18:29Shizthe kernelcache extracted from the preboot partition at $vuid/boot/$policy/System/Caches/com.apple.kernelcache/kernelcache
18:29Shiz(from the top of my head)
18:30marcan__TEXT_EXEC is like 50MB
18:30marcanoutside the filesets
18:31Shizyeah, i do see that
18:31Shizi guess it is, then? but all the files inside are individual seemingly-proper mach-O files
18:31Shizwith adding-ups izes
18:31Shizthe duality of mach-o
18:32marcanthen __TEXT_EXEC is just the text of the kernel itself?
18:32Shizoh, yeah I think it makes sense now
18:33Shizcom.apple.kernel *is* the big blob, and the .kexts are 'inside' but also individually referencable
18:33marcanare they really?
18:33marcanall the iOS research says they were prelinked and not quite complete
18:33Shizis my guess, but maybe not
18:33marcanbut maybe this is different from iOS
18:33Shizotool does complain that the stuff I extract is truncated, so there might be something there
18:34Shizgot too excited because my own parser could parse the etracted stuff again :p
18:35Shizstarting to think it may just be the headers
18:35marcanremember the code *has* to be linked together
18:35marcanbecause CTRR
18:36Shizso yeah, the 'kexts' are first, then the big kernel file, each with at least proper mach-O headers
18:36Shizand I guess those kexts are just the headers, checking now
18:36Shiz(in the fileset entry list, I mean)
18:38roxfanIIRC in some iOS version they reshuffled segments so that all __TEXT are separate from all __DATA; not sure if that's the case with macOS
18:39Shizokay, so each fileset entry seems to be a mach-O header and the string section
18:39Shizcurious
18:39tiagom has quit [Quit: tiagom]
18:41tiagom has joined #asahi-re
18:48roxfani think com.apple.kernel is mostly standalone but kexts are prelinked to refer to addresses inside it
18:48roxfanalso they're all not contiguous in the cache so you can't just dd
18:49roxfanmaybe jtool can extract them, not sure
19:05Shizyeah my conclusion was stupid, my apologies
19:06Shiztbf, i didn't expect them to throw in all the individual headers :P
19:22roxfansome code still relies on valid header being there
21:12mogeryy has quit [Quit: Leaving]
21:20ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
21:21wolf511[m] has joined #asahi-re
21:22DarthCloud has quit [Ping timeout: 240 seconds]
21:28DarthCloud has joined #asahi-re
22:03aratuk has joined #asahi-re
22:07aratuk has quit [Ping timeout: 240 seconds]
22:20parallax has joined #asahi-re
22:41tiagom has quit [Quit: tiagom]
23:26ransom has joined #asahi-re
23:39ransom has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
…