)
{
kern_return_t rval = KERN_FAILURE;
- struct mach_header *mach_hdr = (struct mach_header *) file;
+ struct mach_header *mach_hdr = (struct mach_header *) ((void *) file);
struct load_command *load_hdr = NULL;
struct segment_command *seg_hdr = NULL;
struct section *sects = NULL;
for(i = 0; i < mach_hdr->ncmds; ++i, offset += cmdsize) {
/* Get the load command and size */
- load_hdr = (struct load_command *) (file + offset);
+ load_hdr = (struct load_command *) ((void *) (file + offset));
cmd = load_hdr->cmd;
cmdsize = load_hdr->cmdsize;
kxld_log(kKxldLogLinking, kKxldLogErr, kKxldLogTruncatedMachO));
/* Swap the relocation entries */
- relocs = (struct relocation_info *) (file + sects[j].reloff);
+ relocs = (struct relocation_info *) ((void *) (file + sects[j].reloff));
#if !KERNEL
if (swap) {
swap_relocation_info(relocs, sects[j].nreloc,
#if !KERNEL
/* Swap the symbol table entries */
- symtab = (struct nlist *) (file + symtab_hdr->symoff);
+ symtab = (struct nlist *) ((void *) (file + symtab_hdr->symoff));
if (swap) swap_nlist(symtab, symtab_hdr->nsyms, host_order);
#endif /* !KERNEL */
)
{
kern_return_t rval = KERN_FAILURE;
- struct mach_header_64 *mach_hdr = (struct mach_header_64 *) file;
+ struct mach_header_64 *mach_hdr = (struct mach_header_64 *) ((void *) file);
struct load_command *load_hdr = NULL;
struct segment_command_64 *seg_hdr = NULL;
struct section_64 *sects = NULL;
/* Validate and potentially swap the load commands */
for(i = 0; i < mach_hdr->ncmds; ++i, offset += cmdsize) {
/* Get the load command and size */
- load_hdr = (struct load_command *) (file + offset);
+ load_hdr = (struct load_command *) ((void *) (file + offset));
cmd = load_hdr->cmd;
cmdsize = load_hdr->cmdsize;
switch(cmd) {
case LC_SEGMENT_64:
/* Get and swap the segment header */
- seg_hdr = (struct segment_command_64 *) load_hdr;
+ seg_hdr = (struct segment_command_64 *) ((void *) load_hdr);
#if !KERNEL
if (swap) swap_segment_command_64(seg_hdr, host_order);
#endif /* !KERNEL */
kxld_log(kKxldLogLinking, kKxldLogErr, kKxldLogTruncatedMachO));
/* Swap the relocation entries */
- relocs = (struct relocation_info *) (file + sects[j].reloff);
+ relocs = (struct relocation_info *) ((void *) (file + sects[j].reloff));
#if !KERNEL
if (swap) {
swap_relocation_info(relocs, sects[j].nreloc,
#if !KERNEL
/* Swap the symbol table entries */
- symtab = (struct nlist_64 *) (file + symtab_hdr->symoff);
+ symtab = (struct nlist_64 *) ((void *) (file + symtab_hdr->symoff));
if (swap) swap_nlist_64(symtab, symtab_hdr->nsyms, host_order);
#endif /* !KERNEL */
void unswap_macho(u_char *file, enum NXByteOrder host_order,
enum NXByteOrder target_order)
{
- struct mach_header *hdr = (struct mach_header *) file;
+ struct mach_header *hdr = (struct mach_header *) ((void *) file);
if (!hdr) return;
unswap_macho_32(u_char *file, enum NXByteOrder host_order,
enum NXByteOrder target_order)
{
- struct mach_header *mach_hdr = (struct mach_header *) file;
+ struct mach_header *mach_hdr = (struct mach_header *) ((void *) file);
struct load_command *load_hdr = NULL;
struct segment_command *seg_hdr = NULL;
struct section *sects = NULL;
offset = sizeof(*mach_hdr);
for(i = 0; i < mach_hdr->ncmds; ++i, offset += size) {
- load_hdr = (struct load_command *) (file + offset);
+ load_hdr = (struct load_command *) ((void *) (file + offset));
cmd = load_hdr->cmd;
size = load_hdr->cmdsize;
break;
case LC_SYMTAB:
symtab_hdr = (struct symtab_command *) load_hdr;
- symtab = (struct nlist*) (file + symtab_hdr->symoff);
+ symtab = (struct nlist*) ((void *) (file + symtab_hdr->symoff));
swap_nlist(symtab, symtab_hdr->nsyms, target_order);
swap_symtab_command(symtab_hdr, target_order);
unswap_macho_64(u_char *file, enum NXByteOrder host_order,
enum NXByteOrder target_order)
{
- struct mach_header_64 *mach_hdr = (struct mach_header_64 *) file;
+ struct mach_header_64 *mach_hdr = (struct mach_header_64 *) ((void *) file);
struct load_command *load_hdr = NULL;
struct segment_command_64 *seg_hdr = NULL;
struct section_64 *sects = NULL;
offset = sizeof(*mach_hdr);
for(i = 0; i < mach_hdr->ncmds; ++i, offset += size) {
- load_hdr = (struct load_command *) (file + offset);
+ load_hdr = (struct load_command *) ((void *) (file + offset));
cmd = load_hdr->cmd;
size = load_hdr->cmdsize;
switch(cmd) {
case LC_SEGMENT_64:
- seg_hdr = (struct segment_command_64 *) load_hdr;
+ seg_hdr = (struct segment_command_64 *) ((void *) load_hdr);
sects = (struct section_64 *) &seg_hdr[1];
/* We don't need to unswap relocations because this function is
break;
case LC_SYMTAB:
symtab_hdr = (struct symtab_command *) load_hdr;
- symtab = (struct nlist_64 *) (file + symtab_hdr->symoff);
+ symtab = (struct nlist_64 *) ((void *) (file + symtab_hdr->symoff));
swap_nlist_64(symtab, symtab_hdr->nsyms, target_order);
swap_symtab_command(symtab_hdr, target_order);