From: Nick Clifton <nickc@redhat.com>
To: "Frédéric Rivière" <frederic.riviere@microej.com>
Cc: binutils@sourceware.org
Subject: Re: load of in-place relocation addend in AArch64
Date: Thu, 7 Dec 2023 17:16:41 +0000 [thread overview]
Message-ID: <578e6c40-5e6c-448f-bb76-791ad19db444@redhat.com> (raw)
In-Reply-To: <1aa735f4-ff2d-4334-830e-d23ef154dbba@microej.com>
[-- Attachment #1: Type: text/plain, Size: 1247 bytes --]
Hi Frédéric,
OK, I have produced a small patch (attached) which adds this warning
message to the linker's output:
$ ld test_AArch64_with_REL.o
ld: test_AArch64_with_REL.o: Warning: REL type relocations are not expected for architecture 'aarch64' - support may be incomplete
This warning does not actually stop the link from completing however.
The reason for this is that the code where the relocations are loaded
is shared by other tools, which do still work with REL relocations.
For example the objdump tool is able to display the relocations without
any problems:
$ objdump -r test_AArch64_with_REL.o
BFD: test_AArch64_with_REL.o: Warning: REL type relocations are not expected for architecture 'aarch64' - support may be incomplete
test_AArch64_with_REL.o: file format elf64-littleaarch64
RELOCATION RECORDS FOR [.text.__icetea__virtual__com_is2t_icetea_support_test_BImpl___bar__I]:
OFFSET TYPE VALUE
0000000000000008 R_AARCH64_ABS32 com_is2t_icetea_support_test_AImpl___bar
[...]
This strikes me as a compromise solution at best, but it is better
than the current situation nonetheless.
What do you think ?
Cheers
Nick
[-- Attachment #2: rel.warning.patch --]
[-- Type: text/x-patch, Size: 1589 bytes --]
diff --git a/bfd/elf.c b/bfd/elf.c
index db45d1a074b..02246b1360c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2928,6 +2928,44 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
goto success;
}
+ /* Check to make sure that the target supports this type of relocation.
+ Note - we do not treat lack of support as a failure, since we may
+ just be displaying information from an experimental file that is
+ using an unexpected relocation type. Plus if we 'goto fail' here
+ our error message will be suppressed by the format matching code.
+ Instead we tell the users that they might not be getting the
+ results that they expect. */
+ static bool already_warned = false; /* Only warn once. */
+ if (! already_warned)
+ {
+ bool supported;
+ const char * rel_name;
+
+ switch (hdr->sh_type)
+ {
+ case SHT_REL:
+ supported = get_elf_backend_data (abfd)->may_use_rel_p;
+ rel_name = "REL";
+ break;
+
+ case SHT_RELA:
+ supported = get_elf_backend_data (abfd)->may_use_rela_p;
+ rel_name = "RELA";
+ break;
+
+ default:
+ supported = true;
+ }
+
+ if (! supported)
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%pB: Warning: %s type relocations are not expected for architecture '%s' - supprt may be incomplete"),
+ abfd, rel_name, bfd_printable_name (abfd));
+ already_warned = true;
+ }
+ }
+
/* Get the symbol table. */
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
next prev parent reply other threads:[~2023-12-07 17:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 8:08 Frédéric Rivière
2023-12-06 11:14 ` Nick Clifton
2023-12-06 15:02 ` Frédéric Rivière
2023-12-06 15:31 ` Nick Clifton
2023-12-06 16:56 ` Frédéric Rivière
2023-12-07 17:16 ` Nick Clifton [this message]
2023-12-11 7:51 ` Frédéric Rivière
2024-03-28 7:10 ` Fangrui Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=578e6c40-5e6c-448f-bb76-791ad19db444@redhat.com \
--to=nickc@redhat.com \
--cc=binutils@sourceware.org \
--cc=frederic.riviere@microej.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).