This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch/committed]: Minor fixes in mach-o.c
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils Development <binutils at sourceware dot org>
- Date: Wed, 21 Sep 2011 12:09:55 +0200
- Subject: [patch/committed]: Minor fixes in mach-o.c
Hi,
while working on gas for Darwin x86-64, I noticed a few issues in the mach-o backend. This patch fixes them.
Committed on trunk.
Tristan.
bfd/
2011-09-21 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_convert_section_name_to_bfd): Add comment.
Deals with size limited strings.
(bfd_mach_o_build_commands): Initialize more fields.
Index: bfd/mach-o.c
===================================================================
RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.66
diff -c -r1.66 mach-o.c
*** bfd/mach-o.c 18 Aug 2011 09:28:42 -0000 1.66
--- bfd/mach-o.c 21 Sep 2011 10:09:12 -0000
***************
*** 183,188 ****
--- 183,191 ----
}
}
+ /* Convert Mach-O section name to BFD. Try to use standard names, otherwise
+ forge a new name. SEGNAME and SECTNAME are 16 bytes strings. */
+
static void
bfd_mach_o_convert_section_name_to_bfd
(bfd *abfd, const char *segname, const char *sectname,
***************
*** 199,205 ****
if (*name)
return;
! len = strlen (segname) + 1 + strlen (sectname) + 1;
/* Put "LC_SEGMENT." prefix if the segment name is weird (ie doesn't start
with an underscore. */
--- 202,208 ----
if (*name)
return;
! len = 16 + 1 + 16 + 1;
/* Put "LC_SEGMENT." prefix if the segment name is weird (ie doesn't start
with an underscore. */
***************
*** 214,220 ****
res = bfd_alloc (abfd, len);
if (res == NULL)
return;
! snprintf (res, len, "%s%s.%s", pfx, segname, sectname);
*name = res;
*flags = SEC_NO_FLAGS;
}
--- 217,223 ----
res = bfd_alloc (abfd, len);
if (res == NULL)
return;
! snprintf (res, len, "%s%.16s.%.16s", pfx, segname, sectname);
*name = res;
*flags = SEC_NO_FLAGS;
}
***************
*** 1406,1411 ****
--- 1409,1416 ----
| BFD_MACH_O_PROT_EXECUTE;
seg->initprot = seg->maxprot;
seg->flags = 0;
+ seg->sect_head = NULL;
+ seg->sect_tail = NULL;
/* Create Mach-O sections. */
target_index = 0;