Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker: Preparation for more generic linker relaxation (Batch 1) #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

a4lg
Copy link
Owner

@a4lg a4lg commented Oct 14, 2023

@a4lg a4lg force-pushed the riscv-linker-relax-1 branch from 58f83ba to 7a93854 Compare October 14, 2023 05:02
@a4lg a4lg changed the title Linker: Preparation for more generic linker relaxation (1) Linker: Preparation for more generic linker relaxation (Batch 1) Oct 14, 2023
@a4lg a4lg force-pushed the riscv-linker-relax-1 branch from 7a93854 to 4185b39 Compare October 14, 2023 08:40
@a4lg a4lg added the enhancement New feature or request label Oct 14, 2023
@a4lg a4lg force-pushed the riscv-linker-relax-1 branch 4 times, most recently from e297db2 to daad42a Compare October 19, 2023 03:17
a4lg added 2 commits October 19, 2023 06:58
It does not only deduplicate multiple relaxation feature detection,
but enable more complex features so that querying the feature availability
will get too slow if we perform it per-relocation (not per-section).

Even if that wouldn't happen any time soon, it will improve the
maintainability around the linker relaxation code.

bfd/ChangeLog:

	* elfnn-riscv.c (RISCV_RELAX_RVC, RISCV_RELAX_GP): New.
	(relax_func_t): Add new relax_features argument.
	(_bfd_riscv_relax_call): Likewise.  Move feature detection to
	_bfd_riscv_relax_section.  Use bool for simplicity.
	(_bfd_riscv_relax_lui): Likewise.  Move feature detection to
	_bfd_riscv_relax_section.
	(_bfd_riscv_relax_tls_le): Likewise but features are not used.
	(_bfd_riscv_relax_align): Likewise but features are not used.
	(_bfd_riscv_relax_pc): Likewise.  Move feature detection to
	_bfd_riscv_relax_section.
	(_bfd_riscv_relax_section): Detect relaxation-related features
	and pass the flags to each relaxation function.  Use the PIC
	feature flag generated by itself.
There's not only Global-pointer Relaxation defined by the RISC-V psABI
Specification.  There is also the Zero-page relaxation, making the name
"pcgp" not suitable for storage to PC-relative relocations used in the
linker relaxation passes.

This commit prepares for future changes including proper zero-page
relaxation.

bfd/ChangeLog:

	* elfnn-riscv.c
	(struct riscv_pcgp_hi_reloc): Rename to...
	(struct riscv_pc_relax_hi_reloc): ...here.
	(struct riscv_pcgp_lo_reloc): Rename to...
	(struct riscv_pc_relax_lo_reloc): ...here.
	(riscv_init_pcgp_relocs): Rename to...
	(riscv_init_pc_relax_relocs): ...here.
	(riscv_free_pcgp_relocs): Rename to...
	(riscv_free_pc_relax_relocs): ...here.
	(riscv_record_pcgp_hi_reloc): Rename to...
	(riscv_record_pc_relax_hi_reloc): ...here.
	(riscv_find_pcgp_hi_reloc): Rename to...
	(riscv_find_pc_relax_hi_reloc): ...here.
	(riscv_record_pcgp_lo_reloc): Rename to...
	(riscv_record_pc_relax_lo_reloc): ...here.
	(riscv_find_pcgp_lo_reloc): Rename to...
	(riscv_find_pc_relax_lo_reloc): ...here.
	(riscv_update_pcgp_relocs): Rename to...
	(riscv_update_pc_relax_relocs): ...here.
	(_riscv_relax_delete_bytes, _riscv_relax_delete_piecewise,
	_riscv_relax_delete_immediate, _bfd_riscv_relax_call,
	_bfd_riscv_relax_tls_le, _bfd_riscv_relax_align,
	_bfd_riscv_relax_section): Reflect name changes.
	(_bfd_riscv_relax_lui, _bfd_riscv_relax_pc):
	Likewise.  Also change "GP-relative" to "GP/zero-relative"
	in the function description comment.
@a4lg a4lg force-pushed the riscv-linker-relax-1 branch from daad42a to c74a857 Compare October 19, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant