[prev in list] [next in list] [prev in thread] [next in thread]
List: binutils
Subject: Re: [PATCH v6] MIPS: Reject branch absolute relocs for PIC for linking
From: Hans-Peter Nilsson <hp () bitrange ! com>
Date: 2024-02-22 3:13:51
Message-ID: alpine.BSF.2.20.16.2402212209112.6914 () arjuna ! pair ! com
[Download RAW message or body]
A random comment:
On Wed, 21 Feb 2024, YunQiang Su wrote:
> The asm code like:
> b 8
> will emit absolute relocs like:
> R_MIPS_PC16 *ABS*
>
> If they are included into PIC shared objects or PIE executables,
> the branch target will be like 0x12340000, which will make the
> programs crash.
> ---
> bfd/elfxx-mips.c | 9 +++++++++
> ld/testsuite/ld-mips-elf/mips-elf.exp | 1 +
> ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.d | 5 +++++
> ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.s | 2 ++
> 4 files changed, 17 insertions(+)
> create mode 100644 ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.d
> create mode 100644 ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.s
>
> diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> index 69dd71419ff..9542250dec4 100644
> --- a/bfd/elfxx-mips.c
> +++ b/bfd/elfxx-mips.c
> @@ -9258,6 +9258,15 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> (h) ? h->root.root.string : "a local symbol");
> break;
> default:
> + if (branch_reloc_p (r_type) && r_symndx == STN_UNDEF)
> + {
> + howto = MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, NEWABI_P (abfd));
> + info->callbacks->einfo
> + /* xgettext:c-format */
> + (_("%X%H: relocation %s against `*ABS*' cannot be used"
There's no "*ABS*" in the source and IMHO that'd look confusing
to innocent users. How about "...against an absolute value"?
Or "...against an absolute value or absolute symbol"? Perhaps
the latter is a bit too wordy, but also more complete.
> + " when making a PIC/PIE object\n"),
> + abfd, sec, rel->r_offset, howto->name);
> + }
> break;
brgds, H-P
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic