{
asect->orelocation = location;
canon_reloc_count (asect) = count;
+ if (count != 0)
+ asect->flags |= SEC_RELOC;
+ else
+ asect->flags &= ~SEC_RELOC;
}
/* Write out the relocs. */
{
section->orelocation = relptr;
section->reloc_count = count;
+ if (count != 0)
+ section->flags |= SEC_RELOC;
+ else
+ section->flags &= ~SEC_RELOC;
}
/*
}
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)
}
bfd_set_reloc (obfd, osection, relcount == 0 ? NULL : relpp, relcount);
- if (relcount == 0)
- osection->flags &= ~SEC_RELOC;
}
}
if { ![is_xcoff_format] } {
objcopy_test "pr25662" $src executable "" $ldflags
}
+
+run_dump_test "rename-section-01"
--- /dev/null
+#PROG: objcopy
+#name: objcopy rename-section with flags - keep relocation
+#source: needed-by-reloc.s
+#objcopy: --rename-section .data=myrodata,contents,alloc,load,readonly
+#objdump: -r
+#notarget: alpha*-*-*vms* rx-*-elf [is_som_format] [is_aout_format]
+
+.*: +file format .*
+
+#...
+RELOCATION RECORDS FOR .*myrodata.*:
+OFFSET +TYPE +VALUE
+0+ .*
+#pass
if (size > 0 && ! seginfo->bss)
flags |= SEC_HAS_CONTENTS;
- flags &= ~SEC_RELOC;
x = bfd_set_section_flags (sec, flags);
gas_assert (x);
}
#endif
- if (n)
- {
- flagword flags = bfd_section_flags (sec);
- flags |= SEC_RELOC;
- bfd_set_section_flags (sec, flags);
- bfd_set_reloc (stdoutput, sec, relocs, n);
- }
+ bfd_set_reloc (stdoutput, sec, n ? relocs : NULL, n);
#ifdef SET_SECTION_RELOCS
SET_SECTION_RELOCS (sec, relocs, n);