objcopy renaming section with explicit flags

This tidies SEC_RELOC handling in bfd, in the process fixing a bug
with objcopy when renaming sections.

bfd/
	* reloc.c (_bfd_generic_set_reloc): Set/clear SEC_RELOC depending
	on reloc count.
	* elf64-sparc.c (elf64_sparc_set_reloc): Likewise.
binutils/
	* objcopy.c (copy_relocations_in_section): Remove now unnecessary
	clearing of SEC_RELOC.
	* testsuite/binutils-all/rename-section-01.d: New test.
	* testsuite/binutils-all/objcopy.exp: Run it.
gas/
	* write.c (size_seg): Remove unneccesary twiddle of SEC_RELOC.
	(write_relocs): Likewise.  Always call bfd_set_reloc.
This commit is contained in:
Alan Modra
2022-11-14 08:25:16 +10:30
parent f31e4e02ee
commit 4f5c4fce88
6 changed files with 26 additions and 14 deletions
+1 -6
View File
@@ -4331,10 +4331,7 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
}
if (relsize == 0)
{
bfd_set_reloc (obfd, osection, NULL, 0);
osection->flags &= ~SEC_RELOC;
}
bfd_set_reloc (obfd, osection, NULL, 0);
else
{
if (isection->orelocation != NULL)
@@ -4377,8 +4374,6 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
}
bfd_set_reloc (obfd, osection, relcount == 0 ? NULL : relpp, relcount);
if (relcount == 0)
osection->flags &= ~SEC_RELOC;
}
}