<div dir="ltr">Kevin<div><br></div><div>I have a new patch attached.</div><div><br></div><div>I am fine with only supporting <span style="font-size:13px">LC_SEGMENT_64 or LC_SEGMENT_64</span><span style="font-size:13px">  for the time being but I adding a message in case the extract code encounters a segment other than those types.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">I have added some additional flags to narrow down which segment to dump.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Also, I added a flag and some code to print the section to stderr in a hex format for testing and I've added a test case as well.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Let me known how this looks to you.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Thanks</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">PL</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 5, 2016 at 4:22 PM, Kevin Enderby <span dir="ltr"><<a href="mailto:enderby@apple.com" target="_blank">enderby@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Puyan,<br>
<br>
Seems like the functionality would be easier to test if it didn’t write the output files to the same directory as the input file.  And of course you’ll want to add a test case as the llvm tradition with any changes.<br>
<br>
Also I’m not an llvm style expert but you can likely shorten the logic and not use the a switch statement for your return value from ExtractLoadCommand().  Also it looks like it should get an error with any Mach-O file that has non LC_SEGMENT_64 or LC_SEGMENT_64 commands?  Is that correct and what you want.<br>
<br>
You also might just want to return a bool for success of failure from ExtractSectionData() and your other routines.<br>
<br>
Also it llvm seems to like the shortest bit if code so I don’t think you need the “int Res” and could just use an if statement.<br>
<br>
Kev<br>
<div><div class="h5"><br>
> On Aug 5, 2016, at 4:06 PM, Puyan Lotfi <<a href="mailto:puyan.lotfi.llvm@gmail.com">puyan.lotfi.llvm@gmail.com</a>> wrote:<br>
><br>
> Hi Kevin, All:<br>
><br>
> I have a macho-extract tool kicking around locally that I threw together a while back that simply dumps each section in a MachO to disk, and I've decided it's probably high-time to upstream the functionality into llvm-objdump.<br>
><br>
> Let me know if this looks good enough to check in, or otherwise feedback would be nice too.<br>
><br>
> Thanks<br>
><br>
> PL<br>
><br>
><br>
</div></div>> <llvm-objdump-macho-extract.<wbr>patch><br>
<br>
</blockquote></div><br></div>