NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: toolchain/52427 (VAX text relocations)



The following reply was made to PR toolchain/52427; it has been noted by GNATS.

From: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
To: "gnats-bugs%NetBSD.org@localhost" <gnats-bugs%NetBSD.org@localhost>, netbsd-bugs%netbsd.org@localhost
Cc: 
Subject: Re: toolchain/52427 (VAX text relocations)
Date: Tue, 1 Aug 2023 09:50:05 +0900

 -------- Forwarded Message --------
 Subject: [PATCH] 1/2: toolchain/52427: VAX text relocations
 Date: Mon, 31 Jul 2023 14:29:13 +1000
 From: Kalvis Duckmanton <kalvisd%gmail.com@localhost>
 To: tech-toolchain%netbsd.org@localhost
 
 Hi all,
 
 I'd like to submit the following change to the GNU assembler in NetBSD
 10.99.6 for consideration.  This alters the behaviour of
 tc-vax.c:md_create_long_jump() to emit a jump to a offset from the PC
 instead of a jump to an absolute address.
 
 md_create_long_jump() is used, as far as I can tell, as part of the GNU
 assembler's handling of displacements to branch targets where the
 displacement won't fit in a 16 bit word.
 
 Using an absolute address works but in a shared library ld.elf_so will
 complain about relocations in the text segment.
 
 I think that this should address PR toolchain/52427
 (https://mail-index.netbsd.org/netbsd-bugs/2017/07/25/msg052924.html)
 
 Tested on my machine by compiling Perl for VAX from source and using it.
 
 many thanks
 
 kalvis
 
 ---
   external/gpl3/binutils/dist/gas/config/tc-vax.c | 17 +++++++++--------
   1 file changed, 9 insertions(+), 8 deletions(-)
 
 diff --git a/external/gpl3/binutils/dist/gas/config/tc-vax.c
 b/external/gpl3/binutils/dist/gas/config/tc-vax.c
 index 88548bf72096..30a12c705fed 100644
 --- a/external/gpl3/binutils/dist/gas/config/tc-vax.c
 +++ b/external/gpl3/binutils/dist/gas/config/tc-vax.c
 @@ -2330,18 +2330,19 @@ md_create_short_jump (char *ptr,
 
   void
   md_create_long_jump (char *ptr,
 -                    addressT from_addr ATTRIBUTE_UNUSED,
 -                    addressT to_addr,
 -                    fragS *frag,
 -                    symbolS *to_symbol)
 +                     addressT from_addr,
 +                     addressT to_addr,
 +                     fragS *frag ATTRIBUTE_UNUSED,
 +                     symbolS *to_symbol ATTRIBUTE_UNUSED)
   {
     valueT offset;
 
 -  offset = to_addr - S_GET_VALUE (to_symbol);
 -  *ptr++ = VAX_JMP;            /* Arbitrary jump.  */
 -  *ptr++ = VAX_ABSOLUTE_MODE;
 +  /* account for 1 byte instruction, 1 byte of address specifier and
 +     4 bytes of offset from PC */
 +  offset = to_addr - (from_addr + 1 + 1 + 4);
 +  *ptr++ = VAX_JMP;             /* long jump */
 +  *ptr++ = VAX_PC_RELATIVE_MODE;
     md_number_to_chars (ptr, offset, 4);
 -  fix_new (frag, ptr - frag->fr_literal, 4, to_symbol, (long) 0, 0,
 NO_RELOC);
   }
   ^L
   #ifdef OBJ_VMS
 -- 
 2.20.1
 
 


Home | Main Index | Thread Index | Old Index