diff options
author | Christophe Lyon <christophe.lyon@st.com> | 2009-04-01 15:34:12 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@st.com> | 2009-04-01 15:34:12 +0000 |
commit | e780aef286f394eb642aaf0948cdb6ed3f6b814d (patch) | |
tree | efed8079be4c0b71f6d62c85dd06135922f9fb30 | |
parent | ffbe5983cb2ae6b46f3e50d30f54309bf7fe7012 (diff) | |
download | gdb-e780aef286f394eb642aaf0948cdb6ed3f6b814d.zip gdb-e780aef286f394eb642aaf0948cdb6ed3f6b814d.tar.gz gdb-e780aef286f394eb642aaf0948cdb6ed3f6b814d.tar.bz2 |
2009-04-01 Christophe Lyon <christophe.lyon@st.com>
bfd/
* elf32-arm.c (group_sections): Rewrite loops for better
readability.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 59 |
2 files changed, 31 insertions, 33 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f655ab0..e0ed3a6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2009-04-01 Christophe Lyon <christophe.lyon@st.com> + + * elf32-arm.c (group_sections): Rewrite loops for better + readability. + 2009-03-30 DJ Delorie <dj@redhat.com> * elflink.c (elf_link_input_bfd): Don't try to resolve complex diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index c456fdd..d8106d3 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3525,7 +3525,6 @@ group_sections (struct elf32_arm_link_hash_table *htab, { asection *tail = *list; asection *head; - asection *tp; if (tail == bfd_abs_section_ptr) continue; @@ -3535,38 +3534,35 @@ group_sections (struct elf32_arm_link_hash_table *htab, section may be required for an interrupt vector in bare metal code. */ #define NEXT_SEC PREV_SEC - head = tail; - tp = NULL; - for (;;) - { - asection *h = PREV_SEC (head); - NEXT_SEC (head) = tp; - if (h == NULL) - break; - tp = head; - head = h; - } + head = NULL; + while (tail != NULL) + { + /* Pop from tail. */ + asection *item = tail; + tail = PREV_SEC (item); + + /* Push on head. */ + NEXT_SEC (item) = head; + head = item; + } while (head != NULL) { asection *curr; asection *next; - bfd_size_type total; + bfd_vma stub_group_start = head->output_offset; + bfd_vma end_of_next; curr = head; - total = 0; - while ((next = NEXT_SEC (curr)) != NULL) + while (NEXT_SEC (curr) != NULL) { - if ( (total + next->output_offset - curr->output_offset - + next->size) - < stub_group_size ) - { - total += next->output_offset - curr->output_offset; - } - else + next = NEXT_SEC (curr); + end_of_next = next->output_offset + next->size; + if (end_of_next - stub_group_start >= stub_group_size) + /* End of NEXT is too far from start, so stop. */ break; - - curr = next; + /* Add NEXT to the group. */ + curr = next; } /* OK, the size from the start to the start of CURR is less @@ -3588,18 +3584,15 @@ group_sections (struct elf32_arm_link_hash_table *htab, bytes after the stub section can be handled by it too. */ if (!stubs_always_after_branch) { - total = head->size; + stub_group_start = curr->output_offset + curr->size; + while (next != NULL) { - if ( (total + next->output_offset - head->output_offset - + next->size) - < stub_group_size ) - { - total += next->output_offset - head->output_offset; - } - else + end_of_next = next->output_offset + next->size; + if (end_of_next - stub_group_start >= stub_group_size) + /* End of NEXT is too far from stubs, so stop. */ break; - + /* Add NEXT to the stub group. */ head = next; next = NEXT_SEC (head); htab->stub_group[head->id].link_sec = curr; |