aboutsummaryrefslogtreecommitdiff
path: root/bfd/mach-o.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r--bfd/mach-o.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 03a7144..666cf65 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1,5 +1,5 @@
/* Mach-O support for BFD.
- Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -634,6 +634,7 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
char *sname;
const char *prefix = "LC_SEGMENT";
unsigned int snamelen;
+ flagword flags;
snamelen = strlen (prefix) + 1
+ strlen (section->segname) + 1
@@ -644,7 +645,10 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
return NULL;
sprintf (sname, "%s.%s.%s", prefix, section->segname, section->sectname);
- bfdsec = bfd_make_section_anyway (abfd, sname);
+ flags = SEC_ALLOC;
+ if (!(section->flags & BFD_MACH_O_S_ZEROFILL))
+ flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+ bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, flags);
if (bfdsec == NULL)
return NULL;
@@ -654,11 +658,6 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
bfdsec->filepos = section->offset;
bfdsec->alignment_power = section->align;
- if (section->flags & BFD_MACH_O_S_ZEROFILL)
- bfdsec->flags = SEC_ALLOC;
- else
- bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
-
return bfdsec;
}
@@ -966,7 +965,7 @@ bfd_mach_o_scan_read_dylinker (bfd *abfd,
return -1;
strcpy (sname, prefix);
- bfdsec = bfd_make_section_anyway (abfd, sname);
+ bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
if (bfdsec == NULL)
return -1;
@@ -975,7 +974,6 @@ bfd_mach_o_scan_read_dylinker (bfd *abfd,
bfdsec->size = command->len - 8;
bfdsec->filepos = command->offset + 8;
bfdsec->alignment_power = 0;
- bfdsec->flags = SEC_HAS_CONTENTS;
cmd->section = bfdsec;
@@ -1022,7 +1020,7 @@ bfd_mach_o_scan_read_dylib (bfd *abfd, bfd_mach_o_load_command *command)
return -1;
strcpy (sname, prefix);
- bfdsec = bfd_make_section_anyway (abfd, sname);
+ bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
if (bfdsec == NULL)
return -1;
@@ -1031,7 +1029,6 @@ bfd_mach_o_scan_read_dylib (bfd *abfd, bfd_mach_o_load_command *command)
bfdsec->size = command->len - 8;
bfdsec->filepos = command->offset + 8;
bfdsec->alignment_power = 0;
- bfdsec->flags = SEC_HAS_CONTENTS;
cmd->section = bfdsec;
@@ -1142,14 +1139,13 @@ bfd_mach_o_scan_read_thread (bfd *abfd, bfd_mach_o_load_command *command)
j++;
}
- bfdsec = bfd_make_section (abfd, sname);
+ bfdsec = bfd_make_section_with_flags (abfd, sname, SEC_HAS_CONTENTS);
bfdsec->vma = 0;
bfdsec->lma = 0;
bfdsec->size = cmd->flavours[i].size;
bfdsec->filepos = cmd->flavours[i].offset;
bfdsec->alignment_power = 0x0;
- bfdsec->flags = SEC_HAS_CONTENTS;
cmd->section = bfdsec;
}
@@ -1218,7 +1214,7 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
return -1;
strcpy (sname, prefix);
- bfdsec = bfd_make_section_anyway (abfd, sname);
+ bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
if (bfdsec == NULL)
return -1;
@@ -1227,7 +1223,6 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
bfdsec->size = seg->nsyms * 12;
bfdsec->filepos = seg->symoff;
bfdsec->alignment_power = 0;
- bfdsec->flags = SEC_HAS_CONTENTS;
seg->stabs_segment = bfdsec;
@@ -1237,7 +1232,7 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
return -1;
strcpy (sname, prefix);
- bfdsec = bfd_make_section_anyway (abfd, sname);
+ bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
if (bfdsec == NULL)
return -1;
@@ -1246,7 +1241,6 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
bfdsec->size = seg->strsize;
bfdsec->filepos = seg->stroff;
bfdsec->alignment_power = 0;
- bfdsec->flags = SEC_HAS_CONTENTS;
seg->stabstr_segment = bfdsec;
@@ -1263,6 +1257,7 @@ bfd_mach_o_scan_read_segment (bfd *abfd, bfd_mach_o_load_command *command)
char *sname;
const char *prefix = "LC_SEGMENT";
unsigned int snamelen;
+ flagword flags;
BFD_ASSERT (command->type == BFD_MACH_O_LC_SEGMENT);
@@ -1286,7 +1281,8 @@ bfd_mach_o_scan_read_segment (bfd *abfd, bfd_mach_o_load_command *command)
return -1;
sprintf (sname, "%s.%s", prefix, seg->segname);
- bfdsec = bfd_make_section_anyway (abfd, sname);
+ flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+ bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, flags);
if (bfdsec == NULL)
return -1;
@@ -1295,7 +1291,6 @@ bfd_mach_o_scan_read_segment (bfd *abfd, bfd_mach_o_load_command *command)
bfdsec->size = seg->filesize;
bfdsec->filepos = seg->fileoff;
bfdsec->alignment_power = 0x0;
- bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
seg->segment = bfdsec;