X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Fobjcopy.c;h=6489fbe72f90c85787096bd4d39cb67ab8f58381;hb=a7773afff9035cb0e450478bcfe88a5920957e46;hp=28b9d3bf9291518bffe93e98aa9b9b50a8fff3e2;hpb=37d0d09177dc02e0002ab8b90d9b7bc402af9240;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 28b9d3bf92..6489fbe72f 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -143,10 +143,12 @@ struct section_list #define SECTION_CONTEXT_ALTER_LMA (1 << 5) /* Increment or decrement the section's LMA address. */ #define SECTION_CONTEXT_SET_FLAGS (1 << 6) /* Set the section's flags. */ #define SECTION_CONTEXT_REMOVE_RELOCS (1 << 7) /* Remove relocations for this section. */ +#define SECTION_CONTEXT_SET_ALIGNMENT (1 << 8) /* Set alignment for section. */ bfd_vma vma_val; /* Amount to change by or set to. */ bfd_vma lma_val; /* Amount to change by or set to. */ flagword flags; /* What to set the section flags to. */ + unsigned int alignment; /* Alignment of output section. */ }; static struct section_list *change_sections; @@ -344,8 +346,9 @@ enum command_line_switch OPTION_REMOVE_RELOCS, OPTION_RENAME_SECTION, OPTION_REVERSE_BYTES, - OPTION_SECTION_ALIGNMENT, + OPTION_PE_SECTION_ALIGNMENT, OPTION_SET_SECTION_FLAGS, + OPTION_SET_SECTION_ALIGNMENT, OPTION_SET_START, OPTION_SREC_FORCES3, OPTION_SREC_LEN, @@ -476,8 +479,9 @@ static struct option copy_options[] = {"remove-relocations", required_argument, 0, OPTION_REMOVE_RELOCS}, {"rename-section", required_argument, 0, OPTION_RENAME_SECTION}, {"reverse-bytes", required_argument, 0, OPTION_REVERSE_BYTES}, - {"section-alignment", required_argument, 0, OPTION_SECTION_ALIGNMENT}, + {"section-alignment", required_argument, 0, OPTION_PE_SECTION_ALIGNMENT}, {"set-section-flags", required_argument, 0, OPTION_SET_SECTION_FLAGS}, + {"set-section-alignment", required_argument, 0, OPTION_SET_SECTION_ALIGNMENT}, {"set-start", required_argument, 0, OPTION_SET_START}, {"srec-forceS3", no_argument, 0, OPTION_SREC_FORCES3}, {"srec-len", required_argument, 0, OPTION_SREC_LEN}, @@ -610,6 +614,8 @@ copy_usage (FILE *stream, int exit_status) Warn if a named section does not exist\n\ --set-section-flags =\n\ Set section 's properties to \n\ + --set-section-alignment =\n\ + Set section 's alignment to 2^ bytes\n\ --add-section = Add section found in to output\n\ --update-section =\n\ Update contents of section with\n\ @@ -964,6 +970,7 @@ find_section_list (const char *name, bfd_boolean add, unsigned int context) p->vma_val = 0; p->lma_val = 0; p->flags = 0; + p->alignment = 0; p->next = change_sections; change_sections = p; @@ -1248,7 +1255,7 @@ group_signature (asection *group) static bfd_boolean is_dwo_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) { - const char *name = bfd_get_section_name (abfd, sec); + const char *name = bfd_section_name (sec); int len = strlen (name); return strncmp (name + len - 4, ".dwo", 4) == 0; @@ -1303,17 +1310,17 @@ is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) struct section_list *p; struct section_list *q; - p = find_section_list (bfd_get_section_name (abfd, sec), FALSE, + p = find_section_list (bfd_section_name (sec), FALSE, SECTION_CONTEXT_REMOVE); - q = find_section_list (bfd_get_section_name (abfd, sec), FALSE, + q = find_section_list (bfd_section_name (sec), FALSE, SECTION_CONTEXT_COPY); if (p && q) fatal (_("error: section %s matches both remove and copy options"), - bfd_get_section_name (abfd, sec)); + bfd_section_name (sec)); if (p && is_update_section (abfd, sec)) fatal (_("error: section %s matches both update and remove options"), - bfd_get_section_name (abfd, sec)); + bfd_section_name (sec)); if (p != NULL) return TRUE; @@ -1321,7 +1328,7 @@ is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) return TRUE; } - if ((bfd_get_section_flags (abfd, sec) & SEC_DEBUGGING) != 0) + if ((bfd_section_flags (sec) & SEC_DEBUGGING) != 0) { if (strip_symbols == STRIP_DEBUG || strip_symbols == STRIP_UNNEEDED @@ -1332,7 +1339,7 @@ is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) /* By default we don't want to strip .reloc section. This section has for pe-coff special meaning. See pe-dll.c file in ld, and peXXigen.c in bfd for details. */ - if (strcmp (bfd_get_section_name (abfd, sec), ".reloc") != 0) + if (strcmp (bfd_section_name (sec), ".reloc") != 0) return TRUE; } @@ -1357,7 +1364,7 @@ is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) if (is_strip_section_1 (abfd, sec)) return TRUE; - if ((bfd_get_section_flags (abfd, sec) & SEC_GROUP) != 0) + if ((bfd_section_flags (sec) & SEC_GROUP) != 0) { asymbol *gsym; const char *gname; @@ -1407,7 +1414,7 @@ is_nondebug_keep_contents_section (bfd *ibfd, asection *isection) directory", but that may be the .text section for objects produced by some tools, which it is not sensible to keep. */ if (ibfd->xvec->flavour == bfd_target_coff_flavour) - return (strcmp (bfd_get_section_name (ibfd, isection), ".buildid") == 0); + return (strcmp (bfd_section_name (isection), ".buildid") == 0); return FALSE; } @@ -1458,7 +1465,7 @@ create_new_symbol (struct addsym_node *ptr, bfd *obfd) { asymbol *sym = bfd_make_empty_symbol (obfd); - bfd_asymbol_name (sym) = ptr->symdef; + bfd_set_asymbol_name (sym, ptr->symdef); sym->value = ptr->symval; sym->flags = ptr->flags; if (ptr->section) @@ -1496,7 +1503,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, bfd_boolean rem_leading_char; bfd_boolean add_leading_char; - undefined = bfd_is_und_section (bfd_get_section (sym)); + undefined = bfd_is_und_section (bfd_asymbol_section (sym)); if (add_sym_list) { @@ -1514,7 +1521,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, if (new_name == name && (flags & BSF_SECTION_SYM) != 0) new_name = (char *) find_section_rename (name, NULL); - bfd_asymbol_name (sym) = new_name; + bfd_set_asymbol_name (sym, new_name); name = new_name; } @@ -1525,7 +1532,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, || (remove_leading_char && ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0 || undefined - || bfd_is_com_section (bfd_get_section (sym))))); + || bfd_is_com_section (bfd_asymbol_section (sym))))); /* Check if we will add a new leading character. */ add_leading_char = @@ -1538,14 +1545,14 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, if (rem_leading_char && add_leading_char && !prefix_symbols_string) { name[0] = bfd_get_symbol_leading_char (obfd); - bfd_asymbol_name (sym) = name; + bfd_set_asymbol_name (sym, name); rem_leading_char = FALSE; add_leading_char = FALSE; } /* Remove leading char. */ if (rem_leading_char) - bfd_asymbol_name (sym) = ++name; + bfd_set_asymbol_name (sym, ++name); /* Add new leading char and/or prefix. */ if (add_leading_char || prefix_symbols_string) @@ -1564,7 +1571,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, } strcpy (ptr, name); - bfd_asymbol_name (sym) = n; + bfd_set_asymbol_name (sym, n); name = n; } @@ -1572,7 +1579,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, keep = FALSE; else if ((flags & BSF_KEEP) != 0 /* Used in relocation. */ || ((flags & BSF_SECTION_SYM) != 0 - && ((*bfd_get_section (sym)->symbol_ptr_ptr)->flags + && ((*bfd_asymbol_section (sym)->symbol_ptr_ptr)->flags & BSF_KEEP) != 0)) { keep = TRUE; @@ -1580,7 +1587,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, } else if (relocatable /* Relocatable file. */ && ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0 - || bfd_is_com_section (bfd_get_section (sym)))) + || bfd_is_com_section (bfd_asymbol_section (sym)))) keep = TRUE; else if (bfd_decode_symclass (sym) == 'I') /* Global symbols in $idata sections need to be retained @@ -1591,13 +1598,13 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, else if ((flags & BSF_GLOBAL) != 0 /* Global symbol. */ || (flags & BSF_WEAK) != 0 || undefined - || bfd_is_com_section (bfd_get_section (sym))) + || bfd_is_com_section (bfd_asymbol_section (sym))) keep = strip_symbols != STRIP_UNNEEDED; else if ((flags & BSF_DEBUGGING) != 0) /* Debugging symbol. */ keep = (strip_symbols != STRIP_DEBUG && strip_symbols != STRIP_UNNEEDED && ! convert_debugging); - else if (bfd_coff_get_comdat_section (abfd, bfd_get_section (sym))) + else if (bfd_coff_get_comdat_section (abfd, bfd_asymbol_section (sym))) /* COMDAT sections store special information in local symbols, so we cannot risk stripping any of them. */ keep = TRUE; @@ -1630,7 +1637,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, || is_specified_symbol (name, keep_specific_htab))) keep = TRUE; - if (keep && is_strip_section (abfd, bfd_get_section (sym))) + if (keep && is_strip_section (abfd, bfd_asymbol_section (sym))) keep = FALSE; if (keep) @@ -1996,7 +2003,6 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte unsigned long previous_open_end = 0; long relsize; - relsize = bfd_get_reloc_upper_bound (abfd, sec); if (relsize > 0) { @@ -2013,7 +2019,8 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte } /* Make a copy of the notes and convert to our internal format. - Minimum size of a note is 12 bytes. */ + Minimum size of a note is 12 bytes. Also locate the version + notes and check them. */ pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote)); while (remain >= 12) { @@ -2182,12 +2189,10 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte attribute_type_byte = version_1_seen ? 1 : 3; val_start = attribute_type_byte + 1; - /* The first note should be the first version note. */ - if (pnotes[0].note.namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION) - { - err = _("bad GNU build attribute notes: first note not version note"); - goto done; - } + /* We used to require that the first note be a version note, + but this is no longer enforced. Due to the problems with + linking sections with the same name (eg .gnu.build.note.hot) + we cannot guarantee that the first note will be a version note. */ /* Now merge the notes. The rules are: 1. Preserve the ordering of the notes. @@ -2204,8 +2209,9 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte with a non-empty description field must also be preserved *OR* the description field of the note must be changed to contain the starting address to which it refers. - 6. Notes with the same start and end address can be deleted. */ - for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) + 6. Notes with the same start and end address can be deleted. + 7. FIXME: Elminate duplicate version notes - even function specific ones ? */ + for (pnote = pnotes; pnote < pnotes_end; pnote ++) { int note_type; objcopy_internal_note * back; @@ -2233,7 +2239,6 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte && back->note.namesz == pnote->note.namesz && memcmp (back->note.namedata, pnote->note.namedata, pnote->note.namesz) == 0) { - fprintf (stderr, "DUP FUNXC\n"); duplicate_found = TRUE; pnote->note.type = 0; break; @@ -2723,7 +2728,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) } } - if (! bfd_set_section_size (obfd, padd->section, padd->size)) + if (!bfd_set_section_size (padd->section, padd->size)) { bfd_nonfatal_message (NULL, obfd, padd->section, NULL); return FALSE; @@ -2732,7 +2737,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) pset = find_section_list (padd->name, FALSE, SECTION_CONTEXT_SET_VMA | SECTION_CONTEXT_ALTER_VMA); if (pset != NULL - && ! bfd_set_section_vma (obfd, padd->section, pset->vma_val)) + && !bfd_set_section_vma (padd->section, pset->vma_val)) { bfd_nonfatal_message (NULL, obfd, padd->section, NULL); return FALSE; @@ -2744,9 +2749,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) { padd->section->lma = pset->lma_val; - if (! bfd_set_section_alignment - (obfd, padd->section, - bfd_section_alignment (obfd, padd->section))) + if (!bfd_set_section_alignment + (padd->section, bfd_section_alignment (padd->section))) { bfd_nonfatal_message (NULL, obfd, padd->section, NULL); return FALSE; @@ -2771,7 +2775,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) } osec = pupdate->section->output_section; - if (! bfd_set_section_size (obfd, osec, pupdate->size)) + if (!bfd_set_section_size (osec, pupdate->size)) { bfd_nonfatal_message (NULL, obfd, osec, NULL); return FALSE; @@ -2788,7 +2792,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) { bfd_size_type size; - size = bfd_get_section_size (osec); + size = bfd_section_size (osec); if (size == 0) { bfd_nonfatal_message (NULL, ibfd, osec, _("warning: note section is empty")); @@ -2815,7 +2819,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) else { if (osec->output_section == NULL - || ! bfd_set_section_size (obfd, osec->output_section, merged_size)) + || !bfd_set_section_size (osec->output_section, + merged_size)) { bfd_nonfatal_message (NULL, obfd, osec, _("warning: failed to set merged notes size")); free (merged_notes); @@ -2843,14 +2848,14 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) continue; } - if ((bfd_get_section_flags (ibfd, osec) & SEC_HAS_CONTENTS) == 0) + if ((bfd_section_flags (osec) & SEC_HAS_CONTENTS) == 0) { bfd_nonfatal_message (NULL, ibfd, osec, _("can't dump section - it has no contents")); continue; } - bfd_size_type size = bfd_get_section_size (osec); + bfd_size_type size = bfd_section_size (osec); if (size == 0) { bfd_nonfatal_message (NULL, ibfd, osec, @@ -2943,7 +2948,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) + highest_section->size, /* FIXME: We ought to be using COFF_PAGE_SIZE here or maybe - bfd_get_section_alignment() (if it + bfd_section_alignment() (if it was set) but since this is for PE and we know the required alignment it is easier just to hard code it. */ @@ -2952,7 +2957,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) /* Umm, not sure what to do in this case. */ debuglink_vma = 0x1000; - bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma); + bfd_set_section_vma (gnu_debuglink_section, debuglink_vma); } } } @@ -2986,18 +2991,18 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) bfd_size_type size; bfd_vma gap_start, gap_stop; - flags = bfd_get_section_flags (obfd, osections[i]); + flags = bfd_section_flags (osections[i]); if ((flags & SEC_HAS_CONTENTS) == 0 || (flags & SEC_LOAD) == 0) continue; - size = bfd_section_size (obfd, osections[i]); - gap_start = bfd_section_lma (obfd, osections[i]) + size; - gap_stop = bfd_section_lma (obfd, osections[i + 1]); + size = bfd_section_size (osections[i]); + gap_start = bfd_section_lma (osections[i]) + size; + gap_stop = bfd_section_lma (osections[i + 1]); if (gap_start < gap_stop) { - if (! bfd_set_section_size (obfd, osections[i], - size + (gap_stop - gap_start))) + if (!bfd_set_section_size (osections[i], + size + (gap_stop - gap_start))) { bfd_nonfatal_message (NULL, obfd, osections[i], _("Can't fill gap after section")); @@ -3016,12 +3021,11 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) bfd_vma lma; bfd_size_type size; - lma = bfd_section_lma (obfd, osections[c - 1]); - size = bfd_section_size (obfd, osections[c - 1]); + lma = bfd_section_lma (osections[c - 1]); + size = bfd_section_size (osections[c - 1]); if (lma + size < pad_to) { - if (! bfd_set_section_size (obfd, osections[c - 1], - pad_to - lma)) + if (!bfd_set_section_size (osections[c - 1], pad_to - lma)) { bfd_nonfatal_message (NULL, obfd, osections[c - 1], _("can't add padding")); @@ -3199,7 +3203,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) file_ptr off; left = gaps[i]; - off = bfd_section_size (obfd, osections[i]) - left; + off = bfd_section_size (osections[i]) - left; while (left > 0) { @@ -3768,18 +3772,19 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) const char * name; char *prefix = NULL; bfd_boolean make_nobits; + unsigned int alignment; if (is_strip_section (ibfd, isection)) return; /* Get the, possibly new, name of the output section. */ - name = bfd_section_name (ibfd, isection); - flags = bfd_get_section_flags (ibfd, isection); + name = bfd_section_name (isection); + flags = bfd_section_flags (isection); name = find_section_rename (name, &flags); /* Prefix sections. */ if ((prefix_alloc_sections_string) - && (bfd_get_section_flags (ibfd, isection) & SEC_ALLOC)) + && (bfd_section_flags (isection) & SEC_ALLOC)) prefix = prefix_alloc_sections_string; else if (prefix_sections_string) prefix = prefix_sections_string; @@ -3796,7 +3801,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) make_nobits = FALSE; - p = find_section_list (bfd_section_name (ibfd, isection), FALSE, + p = find_section_list (bfd_section_name (isection), FALSE, SECTION_CONTEXT_SET_FLAGS); if (p != NULL) flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC)); @@ -3828,20 +3833,20 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) if (make_nobits) elf_section_type (osection) = SHT_NOBITS; - size = bfd_section_size (ibfd, isection); + size = bfd_section_size (isection); size = bfd_convert_section_size (ibfd, isection, obfd, size); if (copy_byte >= 0) size = (size + interleave - 1) / interleave * copy_width; else if (extract_symbol) size = 0; - if (! bfd_set_section_size (obfd, osection, size)) + if (!bfd_set_section_size (osection, size)) { err = _("failed to set size"); goto loser; } - vma = bfd_section_vma (ibfd, isection); - p = find_section_list (bfd_section_name (ibfd, isection), FALSE, + vma = bfd_section_vma (isection); + p = find_section_list (bfd_section_name (isection), FALSE, SECTION_CONTEXT_ALTER_VMA | SECTION_CONTEXT_SET_VMA); if (p != NULL) { @@ -3853,14 +3858,14 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) else vma += change_section_address; - if (! bfd_set_section_vma (obfd, osection, vma)) + if (!bfd_set_section_vma (osection, vma)) { err = _("failed to set vma"); goto loser; } lma = isection->lma; - p = find_section_list (bfd_section_name (ibfd, isection), FALSE, + p = find_section_list (bfd_section_name (isection), FALSE, SECTION_CONTEXT_ALTER_LMA | SECTION_CONTEXT_SET_LMA); if (p != NULL) { @@ -3874,11 +3879,16 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) osection->lma = lma; + p = find_section_list (bfd_section_name (isection), FALSE, + SECTION_CONTEXT_SET_ALIGNMENT); + if (p != NULL) + alignment = p->alignment; + else + alignment = bfd_section_alignment (isection); + /* FIXME: This is probably not enough. If we change the LMA we may have to recompute the header for the file as well. */ - if (!bfd_set_section_alignment (obfd, - osection, - bfd_section_alignment (ibfd, isection))) + if (!bfd_set_section_alignment (osection, alignment)) { err = _("failed to set alignment"); goto loser; @@ -3952,12 +3962,12 @@ skip_section (bfd *ibfd, sec_ptr isection, bfd_boolean skip_copy) if (skip_copy && is_merged_note_section (ibfd, isection)) return TRUE; - flags = bfd_get_section_flags (ibfd, isection); + flags = bfd_section_flags (isection); if ((flags & SEC_GROUP) != 0) return TRUE; osection = isection->output_section; - size = bfd_get_section_size (isection); + size = bfd_section_size (isection); if (size == 0 || osection == 0) return TRUE; @@ -3982,7 +3992,7 @@ handle_remove_relocations_option (const char *section_pattern) static bfd_boolean discard_relocations (bfd *ibfd ATTRIBUTE_UNUSED, asection *isection) { - return (find_section_list (bfd_section_name (ibfd, isection), FALSE, + return (find_section_list (bfd_section_name (isection), FALSE, SECTION_CONTEXT_REMOVE_RELOCS) != NULL); } @@ -4127,10 +4137,10 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg) ELF classes of input and output aren't the same. We can't use the output section size since --interleave will shrink the output section. Size will be updated if the section is converted. */ - size = bfd_get_section_size (isection); + size = bfd_section_size (isection); - if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS - && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS) + if (bfd_section_flags (isection) & SEC_HAS_CONTENTS + && bfd_section_flags (osection) & SEC_HAS_CONTENTS) { bfd_byte *memhunk = NULL; @@ -4167,7 +4177,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg) else /* User must pad the section up in order to do this. */ fatal (_("cannot reverse bytes: length of section %s must be evenly divisible by %d"), - bfd_section_name (ibfd, isection), reverse_bytes); + bfd_section_name (isection), reverse_bytes); } if (copy_byte >= 0) @@ -4210,7 +4220,7 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg) } free (memhunk); } - else if ((p = find_section_list (bfd_get_section_name (ibfd, isection), + else if ((p = find_section_list (bfd_section_name (isection), FALSE, SECTION_CONTEXT_SET_FLAGS)) != NULL && (p->flags & SEC_HAS_CONTENTS) != 0) { @@ -4281,9 +4291,9 @@ compare_section_lma (const void *arg1, const void *arg2) return -1; /* Sort sections with the same LMA by size. */ - if (bfd_get_section_size (*sec1) > bfd_get_section_size (*sec2)) + if (bfd_section_size (*sec1) > bfd_section_size (*sec2)) return 1; - else if (bfd_get_section_size (*sec1) < bfd_get_section_size (*sec2)) + else if (bfd_section_size (*sec1) < bfd_section_size (*sec2)) return -1; return 0; @@ -4365,10 +4375,10 @@ write_debugging_info (bfd *obfd, void *dhandle, stabstrsec = bfd_make_section_with_flags (obfd, ".stabstr", flags); if (stabsec == NULL || stabstrsec == NULL - || ! bfd_set_section_size (obfd, stabsec, symsize) - || ! bfd_set_section_size (obfd, stabstrsec, stringsize) - || ! bfd_set_section_alignment (obfd, stabsec, 2) - || ! bfd_set_section_alignment (obfd, stabstrsec, 0)) + || !bfd_set_section_size (stabsec, symsize) + || !bfd_set_section_size (stabstrsec, stringsize) + || !bfd_set_section_alignment (stabsec, 2) + || !bfd_set_section_alignment (stabstrsec, 0)) { bfd_nonfatal_message (NULL, obfd, NULL, _("can't create debugging section")); @@ -5264,6 +5274,33 @@ copy_main (int argc, char *argv[]) } break; + case OPTION_SET_SECTION_ALIGNMENT: + { + struct section_list *p; + const char *s; + int len; + char *name; + int align; + + s = strchr (optarg, '='); + if (s == NULL) + fatal (_("bad format for %s"), "--set-section-alignment"); + + align = atoi(s+1); + if (align < 0) + fatal (_("bad format for %s"), "--set-section-alignment"); + + len = s - optarg; + name = (char *) xmalloc (len + 1); + strncpy (name, optarg, len); + name[len] = '\0'; + + p = find_section_list (name, TRUE, SECTION_CONTEXT_SET_ALIGNMENT); + + p->alignment = align; + } + break; + case OPTION_RENAME_SECTION: { flagword flags; @@ -5459,7 +5496,7 @@ copy_main (int argc, char *argv[]) pe_image_base = parse_vma (optarg, "--image-base"); break; - case OPTION_SECTION_ALIGNMENT: + case OPTION_PE_SECTION_ALIGNMENT: pe_section_alignment = parse_vma (optarg, "--section-alignment"); break;