binutils-gdb/ld/emulparams/hppalinux.sh
John David Anglin a82e3815df hppa: Implement PA 2.0 symbolic relocations for long displacements
The PA 2.0 architecture introduced several new load and store
instructions with long displacements.  These include floating
point loads and stores for word mode, and integer and floating
point loads and stores for double words.  Currently, ld does
not correctly support symbolic relocations for these instructions.

If these are used, ld applies the standard R_PARISC_DPREL14R
relocation and corrupts the instruction.  This change uses
bfd_hppa_insn2fmt to determine the correct relocation format.

We need to check the computed displacement as the immediate
value used in these instruction must be a multiple of 4 or 8
depending on whether the access is for a word or double word.

A misaligned offset can potentially occur if the symbol is not
properly aligned or if $global$ (the global pointer) is not
double word aligned.  $global$ is provided as a .data section
start symbol.  The patch adjusts elf.sc and hppalinux.sh to
align .data to a 8-byte boundary in non-shared and non-pie
links.

2024-04-01  John David Anglin  <danglin@gcc.gnu.org>

	PR ld/31503

bfd/ChangeLog:

	* elf32-hppa.c (final_link_relocate): Output

ld/ChangeLog:

	* emulparams/hppalinux.sh (DATA_SECTION_ALIGNMENT): Define.
	* scripttempl/elf.sc: Align .data section to DATA_SECTION_ALIGNMENT
	when relocating.
2024-04-01 23:00:52 +00:00

36 lines
1.0 KiB
Bash

# If you change this file, please also look at files which source this one:
# hppanbsd.sh
SCRIPT_NAME=elf
ELFSIZE=32
OUTPUT_FORMAT="elf32-hppa-linux"
NO_REL_RELOCS=yes
TEXT_START_ADDR=0x10000
TARGET_PAGE_SIZE=0x10000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
if test "$LD_FLAG" = "N"; then
unset DATA_SEGMENT_ALIGN
unset DATA_SEGMENT_END
unset DATA_SEGMENT_RELRO_END
else
DATA_SEGMENT_ALIGN="ALIGN(${MAXPAGESIZE});\
. = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
fi
DATA_SECTION_ALIGNMENT="${CREATE_SHLIB-${CREATE_PIE-ALIGN(8)}}"
ARCH=hppa
MACHINE=hppa1.1 # We use 1.1 specific features.
NOP=0x08000240
START="_start"
OTHER_READONLY_SECTIONS="
.PARISC.unwind ${RELOCATING-0} : { *(.PARISC.unwind) }"
DATA_START_SYMBOLS='PROVIDE ($global$ = .);'
DATA_PLT=
PLT_BEFORE_GOT=
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
TEMPLATE_NAME=elf
EXTRA_EM_FILE=hppaelf