From 4e2147ff812032547eb25f3183a229373a4a3951 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Fri, 17 Oct 2003 23:03:44 +0000 Subject: [PATCH] * reloc.c (bfd_generic_relax_section): Default-set section->_cooked_size here. (bfd_generic_get_relocated_section_contents): Don't set it here. Explain why. --- bfd/ChangeLog | 7 +++++++ bfd/reloc.c | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9efe0362bbc..c27a6d80a81 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2003-10-18 Hans-Peter Nilsson + + * reloc.c (bfd_generic_relax_section): Default-set + section->_cooked_size here. + (bfd_generic_get_relocated_section_contents): Don't set it here. + Explain why. + 2003-10-17 John David Anglin * elf32-hppa.c (elf32_hppa_relocate_section): Skip relocation if diff --git a/bfd/reloc.c b/bfd/reloc.c index ddb0a4d5733..9ec83eb4b0e 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -4030,7 +4030,8 @@ SYNOPSIS DESCRIPTION Provides default handling for relaxing for back ends which - don't do relaxing -- i.e., does nothing. + don't do relaxing -- i.e., does nothing except make sure that the + final size of the section is set. */ bfd_boolean @@ -4039,6 +4040,11 @@ bfd_generic_relax_section (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *link_info ATTRIBUTE_UNUSED, bfd_boolean *again) { + /* We're not relaxing the section, so just copy the size info if it's + zero. Someone else, like bfd_merge_sections, might have set it, so + don't overwrite a non-zero value. */ + if (section->_cooked_size == 0) + section->_cooked_size = section->_raw_size; *again = FALSE; return TRUE; } @@ -4133,8 +4139,13 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, input_section->_raw_size)) goto error_return; - /* We're not relaxing the section, so just copy the size info. */ - input_section->_cooked_size = input_section->_raw_size; + /* Don't set input_section->_cooked_size here. The caller has set + _cooked_size or called bfd_relax_section, which sets _cooked_size. + Despite using this generic relocation function, some targets perform + target-specific relaxation or string merging, which happens before + this function is called. We do not want to clobber the _cooked_size + they computed. */ + input_section->reloc_done = TRUE; reloc_count = bfd_canonicalize_reloc (input_bfd, -- 2.30.2