/* simple-object-mach-o.c -- routines to manipulate Mach-O object files.
- Copyright 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2010-2023 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
This program is free software; you can redistribute it and/or modify it
size_t index_size;
unsigned int n_wrapped_sects;
size_t wrapper_sect_size;
- off_t wrapper_sect_offset;
+ off_t wrapper_sect_offset = 0;
fetch_32 = (omr->is_big_endian
? simple_object_fetch_big_32
/* Otherwise, make a name like __segment,__section as per the
convention in mach-o asm. */
name = &namebuf[0];
- memset (namebuf, 0, MACH_O_NAME_LEN * 2 + 2);
memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
+ namebuf[MACH_O_NAME_LEN] = '\0';
l = strlen (namebuf);
namebuf[l] = ',';
memcpy (namebuf + l + 1, (char *) sechdr + sectname_offset,
MACH_O_NAME_LEN);
+ namebuf[l + 1 + MACH_O_NAME_LEN] = '\0';
}
simple_object_mach_o_section_info (omr->is_big_endian, is_32, sechdr,
index[4 * i] -= index[0];
index[0] = 0;
+ /* Swap the indices, if required. */
+
+ for (i = 0; i < (nsects_in * 4); ++i)
+ set_32 ((unsigned char *) &index[i], index[i]);
+
sechdr_offset += sechdrsize;
/* Write out the section names.
simple_object_mach_o_release_attributes,
simple_object_mach_o_start_write,
simple_object_mach_o_write_to_file,
- simple_object_mach_o_release_write
+ simple_object_mach_o_release_write,
+ NULL
};