From: Alan Modra Date: Mon, 20 Aug 2001 01:21:08 +0000 (+0000) Subject: * ldlang.c (insert_pad): Use offsetof macro. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0c330a70f2a352d6bfe279336c8337c3d670dba;p=binutils-gdb.git * ldlang.c (insert_pad): Use offsetof macro. (lang_size_sections): Always neuter padding statements. * emultempl/hppaelf.em (hppaelf_delete_padding_statements): Delete. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index e9bb45d33b9..3c53837d17f 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,9 @@ 2001-08-20 Alan Modra + * ldlang.c (insert_pad): Use offsetof macro. + (lang_size_sections): Always neuter padding statements. + * emultempl/hppaelf.em (hppaelf_delete_padding_statements): Delete. + * pe-dll.c (pe_dll_fill_sections): Correct type of "relax" param passed to lang_size_sections. (pe_exe_fill_sections): Likewise. diff --git a/ld/emultempl/hppaelf.em b/ld/emultempl/hppaelf.em index 93e847da064..f367673e54b 100644 --- a/ld/emultempl/hppaelf.em +++ b/ld/emultempl/hppaelf.em @@ -29,8 +29,6 @@ cat >>e${EMULATION_NAME}.c <head; (s = *ps) != NULL; ps = &s->next) - { - switch (s->header.type) - { - - /* We want to recursively walk these sections. */ - case lang_constructors_statement_enum: - hppaelf_delete_padding_statements (&constructor_list); - break; - - case lang_output_section_statement_enum: - hppaelf_delete_padding_statements (&s->output_section_statement.children); - break; - - case lang_group_statement_enum: - hppaelf_delete_padding_statements (&s->group_statement.children); - break; - - case lang_wild_statement_enum: - hppaelf_delete_padding_statements (&s->wild_statement.children); - break; - - /* Here's what we are really looking for. Splice these out of - the list. */ - case lang_padding_statement_enum: - *ps = s->next; - if (*ps == NULL) - list->tail = ps; - break; - - /* We don't care about these cases. */ - case lang_data_statement_enum: - case lang_object_symbols_statement_enum: - case lang_output_statement_enum: - case lang_target_statement_enum: - case lang_input_section_enum: - case lang_input_statement_enum: - case lang_assignment_statement_enum: - case lang_address_statement_enum: - break; - - default: - abort (); - break; - } - } -} - struct hook_stub_info { @@ -281,9 +222,6 @@ hppaelf_layaout_sections_again () to recalculate all the section offsets. This may mean we need to add even more stubs. */ - /* Delete all the padding statements, they're no longer valid. */ - hppaelf_delete_padding_statements (stat_ptr); - /* Resize the sections. */ lang_size_sections (stat_ptr->head, abs_output_section, &stat_ptr->head, 0, (bfd_vma) 0, false); diff --git a/ld/ldlang.c b/ld/ldlang.c index 905d08c1015..4b0a57e8670 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2635,15 +2635,11 @@ insert_pad (ptr, fill, alignment_needed, output_section, dot) bfd_vma dot; { lang_statement_union_type *pad; - size_t ptr_off; - /* ptr_off is zero, but let's not be too fast and loose with - pointers. */ - ptr_off = ((char *) &((lang_statement_union_type *) 0)->header.next - - (char *) 0); + pad = ((lang_statement_union_type *) + ((char *) ptr - offsetof (lang_statement_union_type *, header.next))); if (ptr != &statement_list.head - && ((pad = (lang_statement_union_type *) ((char *) ptr - ptr_off)) - ->header.type == lang_padding_statement_enum) + && pad->header.type == lang_padding_statement_enum) && pad->padding_statement.output_section == output_section) { /* Use the existing pad statement. The above test on output @@ -3163,18 +3159,12 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax) break; case lang_padding_statement_enum: - if (relax) - { - /* If we are relaxing, and this is not the first pass, - we need to allow padding to shrink. If padding is - needed on this pass, it will be added back in. */ - s->padding_statement.size = 0; - break; - } - - dot += s->padding_statement.size / opb; - output_section_statement->bfd_section->_raw_size += - s->padding_statement.size; + /* If this is the first time lang_size_sections is called, + we won't have any padding statements. If this is the + second or later passes when relaxing, we should allow + padding to shrink. If padding is needed on this pass, it + will be added back in. */ + s->padding_statement.size = 0; break; case lang_group_statement_enum: @@ -3188,8 +3178,7 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax) FAIL (); break; - /* This can only get here when relaxing is turned on. */ - + /* We can only get here when relaxing is turned on. */ case lang_address_statement_enum: break; }