Add new segment to the existing Mach-O file

Questions and Answers about all things *OS (macOS, iOS, tvOS, watchOS)

Add new segment to the existing Mach-O file

Postby MaxBrein » Fri Aug 01, 2014 11:58 pm

I'm looking for way to add a new segment with section to a existed file.

The segment will contain zero sized section, so content doesnt matter.
As I understand I should add new load command LC_SEGMENT to a macho header ? Or I should allocate a space for section too ?
MaxBrein
 
Posts: 5
Joined: Sat May 17, 2014 12:48 pm

Re: Add new segment to the existing Mach-O file

Postby morpheus » Fri May 08, 2015 10:31 pm

Another question I missed...

Adding a new load command is basically the way to do it: an LC_SEGMENT contains 1 or more sections in it. Sections are parts of the segments. So you basically need to do what codesign_allocate does - i.e. create a new load command (LC_SEGMENT), inject it anywhere within the Mach-O, and rewrite the header. The functionality exists (albeit hidden) in tool already.
morpheus
Site Admin
 
Posts: 532
Joined: Thu Apr 11, 2013 6:24 pm


Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 2 guests