From 41e8af905db3b29fa5ce6dde1aa1667886b894cf Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 4 Jul 2008 13:18:40 -0400 Subject: [PATCH] Store alignment as an exponent base 2, like bfd. Signed-off-by: Anders Kaseorg --- objcommon.c | 2 +- objmanip.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/objcommon.c b/objcommon.c index a70dfd7..037647b 100644 --- a/objcommon.c +++ b/objcommon.c @@ -62,7 +62,7 @@ struct supersect *fetch_supersect(bfd *abfd, asection *sect, vec_resize(&new->contents, bfd_get_section_size(sect)); assert(bfd_get_section_contents (abfd, sect, new->contents.data, 0, new->contents.size)); - new->alignment = 1 << bfd_get_section_alignment(abfd, sect); + new->alignment = bfd_get_section_alignment(abfd, sect); vec_init(&new->relocs); vec_reserve(&new->relocs, bfd_get_reloc_upper_bound(abfd, sect)); diff --git a/objmanip.c b/objmanip.c index 2d0c8f4..9401faf 100644 --- a/objmanip.c +++ b/objmanip.c @@ -302,13 +302,13 @@ void rm_from_special(bfd *ibfd, struct specsect *s) struct supersect *ss = fetch_supersect(ibfd, isection, &isyms); struct void_vec orig_contents; vec_move(&orig_contents, &ss->contents); - size_t pad = align(orig_contents.size, ss->alignment) - + size_t pad = align(orig_contents.size, 1 << ss->alignment) - orig_contents.size; memset(vec_grow(&orig_contents, pad), 0, pad); struct arelentp_vec orig_relocs; vec_move(&orig_relocs, &ss->relocs); - int entry_size = align(s->entry_size, ss->alignment); + int entry_size = align(s->entry_size, 1 << ss->alignment); int relocs_per_entry = s->odd_relocs ? 2 : 1; assert((orig_contents.size / entry_size) * relocs_per_entry == orig_relocs.size); @@ -454,10 +454,7 @@ void setup_section(bfd *ibfd, asection *isection, void *obfdarg) assert(bfd_set_section_vma(obfd, osection, vma)); osection->lma = isection->lma; - assert(bfd_set_section_alignment(obfd, - osection, - bfd_section_alignment(ibfd, - isection))); + assert(bfd_set_section_alignment(obfd, osection, ss->alignment)); osection->entsize = isection->entsize; isection->output_section = osection; isection->output_offset = 0; -- 2.11.4.GIT