* [PATCH 1/2] LoongArch: remove R_LARCH_{SUB,ADD}24
@ 2022-05-13 8:56 Huang Pei
2022-05-13 8:56 ` [PATCH 2/2] LoongArch: set elf_backend_default_execstack to 0 Huang Pei
0 siblings, 1 reply; 2+ messages in thread
From: Huang Pei @ 2022-05-13 8:56 UTC (permalink / raw)
To: Zhensong Liu, binutils, Chenghua Xu
Relocation R_LARCH_{SUB,ADD}{8,16,24,32,64} is used for address/offset
field in DWARF/.eh_frame, but R_LARCH_{SUB,ADD}24 does not make sense,
since:
+. 24bit-width relocation is not friendly to alignment handling in RISC
+. there is no uint24/int24 type in LA psABI
Fortunately, neither of these two relocation is used. So we can
safely remove them.
See psABI change proposal:
https://github.com/loongson/LoongArch-Documentation/issues/51
bfd/
* bfd-in2.h: remove BFD_RELOC_LARCH_{ADD,SUB}24
* libbfd.h: Likewise
* reloc.c: Likewise
* elfxx-loongarch.c: remove howto for R_LARCH_{SUB,ADD}24
* elfnn-loongarch.c: remove R_LARCH_{ADD,SUB}24
gas/
* config/tc-loongarch.c: Likewise
include/
* elf/loongarch.h: Likewise
---
bfd/bfd-in2.h | 2 --
bfd/elfnn-loongarch.c | 4 ----
bfd/elfxx-loongarch.c | 34 ++--------------------------------
bfd/libbfd.h | 2 --
bfd/reloc.c | 4 ----
gas/config/tc-loongarch.c | 15 +++++----------
include/elf/loongarch.h | 4 ++--
7 files changed, 9 insertions(+), 56 deletions(-)
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 50e26fc691d..be00a4e5514 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -6297,12 +6297,10 @@ assembler and not (currently) written to any object files. */
BFD_RELOC_LARCH_SOP_POP_32_U,
BFD_RELOC_LARCH_ADD8,
BFD_RELOC_LARCH_ADD16,
- BFD_RELOC_LARCH_ADD24,
BFD_RELOC_LARCH_ADD32,
BFD_RELOC_LARCH_ADD64,
BFD_RELOC_LARCH_SUB8,
BFD_RELOC_LARCH_SUB16,
- BFD_RELOC_LARCH_SUB24,
BFD_RELOC_LARCH_SUB32,
BFD_RELOC_LARCH_SUB64,
BFD_RELOC_UNUSED };
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 5b44901b9e0..e4cd9fa107e 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -1768,7 +1768,6 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section,
case R_LARCH_ADD8:
case R_LARCH_ADD16:
- case R_LARCH_ADD24:
case R_LARCH_ADD32:
case R_LARCH_ADD64:
r = loongarch_check_offset (rel, input_section);
@@ -1781,7 +1780,6 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section,
case R_LARCH_SUB8:
case R_LARCH_SUB16:
- case R_LARCH_SUB24:
case R_LARCH_SUB32:
case R_LARCH_SUB64:
r = loongarch_check_offset (rel, input_section);
@@ -2181,12 +2179,10 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
case R_LARCH_ADD8:
case R_LARCH_ADD16:
- case R_LARCH_ADD24:
case R_LARCH_ADD32:
case R_LARCH_ADD64:
case R_LARCH_SUB8:
case R_LARCH_SUB16:
- case R_LARCH_SUB24:
case R_LARCH_SUB32:
case R_LARCH_SUB64:
if (resolved_dynly)
diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
index 6f7c82297c5..c0c4b477af6 100644
--- a/bfd/elfxx-loongarch.c
+++ b/bfd/elfxx-loongarch.c
@@ -524,23 +524,7 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
false, /* pcrel_offset */
BFD_RELOC_LARCH_ADD16, /* bfd_reloc_code_real_type */
NULL), /* adjust_reloc_bits */
-
- LOONGARCH_HOWTO (R_LARCH_ADD24, /* type (49). */
- 0, /* rightshift. */
- 2, /* size. */
- 24, /* bitsize. */
- false, /* pc_relative. */
- 0, /* bitpos. */
- complain_overflow_signed, /* complain_on_overflow. */
- bfd_elf_generic_reloc, /* special_function. */
- "R_LARCH_ADD24", /* name. */
- false, /* partial_inplace. */
- 0, /* src_mask */
- ALL_ONES, /* dst_mask */
- false, /* pcrel_offset */
- BFD_RELOC_LARCH_ADD24, /* bfd_reloc_code_real_type */
- NULL), /* adjust_reloc_bits */
-
+ LOONGARCH_EMPTY_HOWTO(49),
LOONGARCH_HOWTO (R_LARCH_ADD32, /* type (50). */
0, /* rightshift. */
2, /* size. */
@@ -605,21 +589,7 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
BFD_RELOC_LARCH_SUB16, /* bfd_reloc_code_real_type */
NULL), /* adjust_reloc_bits */
- LOONGARCH_HOWTO (R_LARCH_SUB24, /* type (54). */
- 0, /* rightshift. */
- 2, /* size. */
- 24, /* bitsize. */
- false, /* pc_relative. */
- 0, /* bitpos. */
- complain_overflow_signed, /* complain_on_overflow. */
- bfd_elf_generic_reloc, /* special_function. */
- "R_LARCH_SUB24", /* name. */
- false, /* partial_inplace. */
- 0, /* src_mask */
- ALL_ONES, /* dst_mask */
- false, /* pcrel_offset */
- BFD_RELOC_LARCH_SUB24, /* bfd_reloc_code_real_type */
- NULL), /* adjust_reloc_bits */
+ LOONGARCH_EMPTY_HOWTO(54),
LOONGARCH_HOWTO (R_LARCH_SUB32, /* type (55). */
0, /* rightshift. */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 8c02e29eebd..ab35ef6518f 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -3453,12 +3453,10 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_LARCH_SOP_POP_32_U",
"BFD_RELOC_LARCH_ADD8",
"BFD_RELOC_LARCH_ADD16",
- "BFD_RELOC_LARCH_ADD24",
"BFD_RELOC_LARCH_ADD32",
"BFD_RELOC_LARCH_ADD64",
"BFD_RELOC_LARCH_SUB8",
"BFD_RELOC_LARCH_SUB16",
- "BFD_RELOC_LARCH_SUB24",
"BFD_RELOC_LARCH_SUB32",
"BFD_RELOC_LARCH_SUB64",
"@@overflow: BFD_RELOC_UNUSED@@",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 5098e0ab09f..4aea37f8620 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8245,8 +8245,6 @@ ENUMX
BFD_RELOC_LARCH_ADD8
ENUMX
BFD_RELOC_LARCH_ADD16
-ENUMX
- BFD_RELOC_LARCH_ADD24
ENUMX
BFD_RELOC_LARCH_ADD32
ENUMX
@@ -8255,8 +8253,6 @@ ENUMX
BFD_RELOC_LARCH_SUB8
ENUMX
BFD_RELOC_LARCH_SUB16
-ENUMX
- BFD_RELOC_LARCH_SUB24
ENUMX
BFD_RELOC_LARCH_SUB32
ENUMX
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index 08203d291bd..4808c73fc70 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -1141,13 +1141,12 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
fix_reloc_insn (fixP, (bfd_vma)stack_top, buf);
break;
- case BFD_RELOC_64:
case BFD_RELOC_32:
- if (fixP->fx_subsy)
- {
- case BFD_RELOC_24:
+ case BFD_RELOC_64:
case BFD_RELOC_16:
case BFD_RELOC_8:
+ if (fixP->fx_subsy)
+ {
fixP->fx_next = xmemdup (fixP, sizeof (*fixP), sizeof (*fixP));
fixP->fx_next->fx_addsy = fixP->fx_subsy;
fixP->fx_next->fx_subsy = NULL;
@@ -1164,10 +1163,6 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
fixP->fx_r_type = BFD_RELOC_LARCH_ADD32;
fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB32;
break;
- case BFD_RELOC_24:
- fixP->fx_r_type = BFD_RELOC_LARCH_ADD24;
- fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB24;
- break;
case BFD_RELOC_16:
fixP->fx_r_type = BFD_RELOC_LARCH_ADD16;
fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB16;
@@ -1176,8 +1171,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
fixP->fx_r_type = BFD_RELOC_LARCH_ADD8;
fixP->fx_next->fx_r_type = BFD_RELOC_LARCH_SUB8;
break;
- default:
- break;
+ default:
+ break;
}
md_number_to_chars (buf, 0, fixP->fx_size);
if (fixP->fx_next->fx_addsy == NULL)
diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h
index b7aa4ff069c..796ef8b8614 100644
--- a/include/elf/loongarch.h
+++ b/include/elf/loongarch.h
@@ -77,12 +77,12 @@ RELOC_NUMBER (R_LARCH_SOP_POP_32_U, 46)
/* Used by the static linker for relocating non .text. */
RELOC_NUMBER (R_LARCH_ADD8, 47)
RELOC_NUMBER (R_LARCH_ADD16, 48)
-RELOC_NUMBER (R_LARCH_ADD24, 49)
+/* deprecated, 49 not used */
RELOC_NUMBER (R_LARCH_ADD32, 50)
RELOC_NUMBER (R_LARCH_ADD64, 51)
RELOC_NUMBER (R_LARCH_SUB8, 52)
RELOC_NUMBER (R_LARCH_SUB16, 53)
-RELOC_NUMBER (R_LARCH_SUB24, 54)
+/* deprecated, 54 not used */
RELOC_NUMBER (R_LARCH_SUB32, 55)
RELOC_NUMBER (R_LARCH_SUB64, 56)
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] LoongArch: set elf_backend_default_execstack to 0
2022-05-13 8:56 [PATCH 1/2] LoongArch: remove R_LARCH_{SUB,ADD}24 Huang Pei
@ 2022-05-13 8:56 ` Huang Pei
0 siblings, 0 replies; 2+ messages in thread
From: Huang Pei @ 2022-05-13 8:56 UTC (permalink / raw)
To: Zhensong Liu, binutils, Chenghua Xu
Partial revert 5a91f93b983184c64b3a9332f5f4339d17941d76, since LA
comments out "#define elf_backend_default_execstack 0" by mistake.
New architecture like loongarch/riscv/arm64 demands noexecstack
without .note.GNU-stack section, that is what LA had intended to
bfd/
* elfnn-loongarch.c:restore elf_backend_default_exec
ld/
* testsuite/ld-elf/elf.exp: restore loongarch
---
bfd/elfnn-loongarch.c | 1 +
ld/testsuite/ld-elf/elf.exp | 1 +
2 files changed, 2 insertions(+)
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index e4cd9fa107e..94c8e8269d3 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -130,6 +130,7 @@ struct loongarch_elf_link_hash_table
#define elf_backend_got_header_size (GOT_ENTRY_SIZE * 1)
#define elf_backend_want_dynrelro 1
+#define elf_backend_default_execstack 0
/* Generate a PLT header. */
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index ebb5ba090bf..e33a0d08831 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -186,6 +186,7 @@ proc target_defaults_to_execstack {} {
|| [istarget "*-*-nacl"]
|| [istarget "arc*-*-*"]
|| [istarget "ia64*-*-*"]
+ || [istarget "loongarch*-*-*"]
|| [istarget "nios2*-*-*"]
|| [istarget "powerpc64*-*-*"]
|| [istarget "riscv*-*-*"]
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-13 8:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 8:56 [PATCH 1/2] LoongArch: remove R_LARCH_{SUB,ADD}24 Huang Pei
2022-05-13 8:56 ` [PATCH 2/2] LoongArch: set elf_backend_default_execstack to 0 Huang Pei
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).