Closed yongyan-gh closed 3 years ago
Hi @yongyan-gh! Many thanks for your PR. I'll probably have a look at it on weekend. Maybe earlier, if some spare time shows up ;)
Thank you @konrad-kruczynski !
cc @eddynaka @michaelcfanning
Populated couple missing fields in Mach-O Section: reloff / nreloc / flags according to https://opensource.apple.com/source/cctools/cctools-870/include/mach-o/loader.h
struct section { /* for 32-bit architectures */
char sectname[16]; /* name of this section */
char segname[16]; /* segment this section goes in */
uint32_t addr; /* memory address of this section */
uint32_t size; /* size in bytes of this section */
uint32_t offset; /* file offset of this section */
uint32_t align; /* section alignment (power of 2) */
uint32_t reloff; /* file offset of relocation entries */
uint32_t nreloc; /* number of relocation entries */
uint32_t flags; /* flags (section type and attributes)*/
uint32_t reserved1; /* reserved (for offset or index) */
uint32_t reserved2; /* reserved (for count or sizeof) */
};
struct section_64 { /* for 64-bit architectures */
char sectname[16]; /* name of this section */
char segname[16]; /* segment this section goes in */
uint64_t addr; /* memory address of this section */
uint64_t size; /* size in bytes of this section */
uint32_t offset; /* file offset of this section */
uint32_t align; /* section alignment (power of 2) */
uint32_t reloff; /* file offset of relocation entries */
uint32_t nreloc; /* number of relocation entries */
uint32_t flags; /* flags (section type and attributes)*/
uint32_t reserved1; /* reserved (for offset or index) */
uint32_t reserved2; /* reserved (for count or sizeof) */
uint32_t reserved3; /* reserved */
};
Looks fine, I'll merge it, then add the necessary test file and bump version.
Fix InvalidOperation error when parsing a Mach-O object file. Fix for #77
According to this article:
For Mach-O object file I can see the only 1 segment name is empty and section names are set.
Since binary files are not allowed to be checked-in, attached the binary file here which is used by test I added. simple-mach-o-object.zip