* [binutils-gdb] ld: print branch fixups into the map file for ppc elf targets
@ 2023-11-08 8:07 Cl?ment Chigot
0 siblings, 0 replies; only message in thread
From: Cl?ment Chigot @ 2023-11-08 8:07 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fb2908093576cc469c5ee8404070c8521631c019
commit fb2908093576cc469c5ee8404070c8521631c019
Author: Clément Chigot <chigot@adacore.com>
Date: Mon Nov 6 10:50:23 2023 +0100
ld: print branch fixups into the map file for ppc elf targets
In a safety context, it could interesting to track the trampolines being
generated, ensuring there are expected or not.
bfd/ChangeLog:
* elf32-ppc.c (ppc_elf_relax_section): Log branch fixups.
ld/ChangeLog:
* ld.texi (--print-map): Add new item about fixups.
Diff:
---
bfd/elf32-ppc.c | 12 +++++++++---
ld/ld.texi | 11 +++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 5622aaa30c0..bdbd1b4fb36 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -6169,7 +6169,7 @@ ppc_elf_relax_section (bfd *abfd,
asection *tsec;
struct one_branch_fixup *f;
size_t insn_offset = 0;
- bfd_vma max_branch_offset = 0, val;
+ bfd_vma max_branch_offset = 0, val, reladdr;
bfd_byte *hit_addr;
unsigned long t0;
struct elf_link_hash_entry *h;
@@ -6415,6 +6415,7 @@ ppc_elf_relax_section (bfd *abfd,
continue;
roff = irel->r_offset;
+ reladdr = isec->output_section->vma + isec->output_offset + roff;
/* Avoid creating a lot of unnecessary fixups when
relocatable if the output section size is such that a
@@ -6433,10 +6434,9 @@ ppc_elf_relax_section (bfd *abfd,
final link, so do not presume they remain in range. */
|| tsec->output_section == isec->output_section))
{
- bfd_vma symaddr, reladdr;
+ bfd_vma symaddr;
symaddr = tsec->output_section->vma + tsec->output_offset + toff;
- reladdr = isec->output_section->vma + isec->output_offset + roff;
if (symaddr - reladdr + max_branch_offset
< 2 * max_branch_offset)
continue;
@@ -6507,6 +6507,12 @@ ppc_elf_relax_section (bfd *abfd,
irel->r_info = ELF32_R_INFO (0, R_PPC_NONE);
}
+ link_info->callbacks->minfo
+ (_("%pB: Adjusting branch at 0x%V towards \"%s\" in section %s\n"),
+ abfd, reladdr,
+ (h && h->root.root.string? h->root.root.string : "<unknown>"),
+ f->tsec->name);
+
/* Get the section contents. */
if (contents == NULL)
{
diff --git a/ld/ld.texi b/ld/ld.texi
index f710c02c3d4..1c132561d71 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -920,6 +920,17 @@ Updated property 0xc0010001 (0x1) to merge foo.o (0x1) and bar.o (0x1)
This indicates that property 0xc0010001 value is updated to 0x1 in output
when merging properties in @file{foo.o}, whose 0xc0010001 property value
is 0x1, and @file{bar.o}, whose 0xc0010001 property value is 0x1.
+
+@item
+On some ELF targets, a list of fixups inserted by @option{--relax}
+
+@smallexample
+foo.o: Adjusting branch at 0x00000008 towards "far" in section .text
+@end smallexample
+
+This indicates that the branch at 0x00000008 in foo.o, targeting
+the symbol "far" in section .text, has been replaced by a trampoline.
+
@end itemize
@cindex link map discarded
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-08 8:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08 8:07 [binutils-gdb] ld: print branch fixups into the map file for ppc elf targets Cl?ment Chigot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).