Sourceware Bugzilla – Attachment 15270 Details for
Bug 31179
RISC-V: The SET/ADD/SUB fix breaks ABI compatibility with 2.41 objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed solution with the tag to keep compatible
0001-RISC-V-PR31179-Add-a-reserved-elf-attribute-tag-for-.patch (text/plain), 4.45 KB, created by
Nelson Chu
on 2023-12-22 05:52:04 UTC
(
hide
)
Description:
proposed solution with the tag to keep compatible
Filename:
MIME Type:
Creator:
Nelson Chu
Created:
2023-12-22 05:52:04 UTC
Size:
4.45 KB
patch
obsolete
>From 43bfb743d24d95354aa94ff36bca96abff521c93 Mon Sep 17 00:00:00 2001 >From: Nelson Chu <nelson@rivosinc.com> >Date: Fri, 22 Dec 2023 13:34:39 +0800 >Subject: [PATCH] RISC-V: PR31179, Add a reserved elf attribute tag for > compatible. > >The object which marked by the tag means it won't have any non-zero >addend in SUB_ULEB128, so we don't need to ignore them to get the >correct calculation. Since the tag is non-standard in psabi, so >need use elf_other_obj_attributes_proc rather than >elf_known_obj_attributes_proc api to access. >--- > bfd/elfnn-riscv.c | 27 ++++++++++++++++++++++++--- > binutils/readelf.c | 15 +++++++++++++++ > gas/config/tc-riscv.c | 8 ++++++++ > include/elf/riscv.h | 5 ++++- > 4 files changed, 51 insertions(+), 4 deletions(-) > >diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c >index 6a1f1d9884f..f3de6e6cdc8 100644 >--- a/bfd/elfnn-riscv.c >+++ b/bfd/elfnn-riscv.c >@@ -1735,9 +1735,30 @@ perform_relocation (const reloc_howto_type *howto, > if (howto->pc_relative) > value -= sec_addr (input_section) + rel->r_offset; > >- /* PR31179, ignore the non-zero addend of R_RISCV_SUB_ULEB128. */ >- if (ELFNN_R_TYPE (rel->r_info) != R_RISCV_SUB_ULEB128) >- value += rel->r_addend; >+ switch (ELFNN_R_TYPE (rel->r_info)) >+ { >+ case R_RISCV_SUB_ULEB128: >+ { >+ /* PR31179, ignore the non-zero addend of R_RISCV_SUB_ULEB128. */ >+ obj_attribute_list *list = elf_other_obj_attributes_proc (input_bfd); >+ for (; list; list = list->next) >+ if (list->tag == Tag_RISCV_uleb128_zero_addend && list->attr.i) >+ { >+ value -= rel->r_addend; >+ break; >+ } >+ } >+ break; >+ case R_RISCV_SUB6: >+ case R_RISCV_SUB8: >+ case R_RISCV_SUB16: >+ case R_RISCV_SUB32: >+ case R_RISCV_SUB64: >+ value -= rel->r_addend; >+ break; >+ default: >+ value += rel->r_addend; >+ } > > switch (ELFNN_R_TYPE (rel->r_info)) > { >diff --git a/binutils/readelf.c b/binutils/readelf.c >index 775106fb99c..1eb4f773995 100644 >--- a/binutils/readelf.c >+++ b/binutils/readelf.c >@@ -18440,6 +18440,8 @@ static struct riscv_attr_tag_t riscv_attr_tag[] = > T(priv_spec_revision), > T(unaligned_access), > T(stack_align), >+ /* Non-standard. */ >+ T(uleb128_zero_addend), > #undef T > }; > >@@ -18496,6 +18498,19 @@ display_riscv_attribute (unsigned char *p, > case Tag_RISCV_arch: > p = display_tag_value (-1, p, end); > break; >+ /* Non-standard. */ >+ case Tag_RISCV_uleb128_zero_addend: >+ READ_ULEB (val, p, end); >+ switch (val) >+ { >+ case 0: >+ printf (_("no\n")); >+ break; >+ case 1: >+ printf (_("yes\n")); >+ break; >+ } >+ break; > default: > return display_tag_value (tag, p, end); > } >diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c >index b902c6ba2c1..9a825310dd8 100644 >--- a/gas/config/tc-riscv.c >+++ b/gas/config/tc-riscv.c >@@ -5120,6 +5120,7 @@ riscv_insert_uleb128_fixes (bfd *abfd ATTRIBUTE_UNUSED, > { > segment_info_type *seginfo = seg_info (sec); > struct frag *fragP; >+ bool generate_tag = false; > > subseg_set (sec, 0); > >@@ -5152,7 +5153,11 @@ riscv_insert_uleb128_fixes (bfd *abfd ATTRIBUTE_UNUSED, > fix_new_exp (fragP, fragP->fr_fix, 0, > exp_dup, 0, BFD_RELOC_RISCV_SUB_ULEB128); > free ((void *) exp_dup); >+ generate_tag = true; > } >+ >+ if (generate_tag) >+ bfd_elf_add_proc_attr_int (abfd, Tag_RISCV_uleb128_zero_addend, 1); > } > > /* Called after all assembly has been done. */ >@@ -5198,12 +5203,15 @@ riscv_convert_symbolic_attribute (const char *name) > /* When you modify this table you should > also modify the list in doc/c-riscv.texi. */ > #define T(tag) {#tag, Tag_RISCV_##tag}, {"Tag_RISCV_" #tag, Tag_RISCV_##tag} >+ /* Standard. */ > T(arch), > T(priv_spec), > T(priv_spec_minor), > T(priv_spec_revision), > T(unaligned_access), > T(stack_align), >+ /* Non-standard. */ >+ T(uleb128_zero_addend), > #undef T > }; > >diff --git a/include/elf/riscv.h b/include/elf/riscv.h >index 56d419c665b..9c091f3154c 100644 >--- a/include/elf/riscv.h >+++ b/include/elf/riscv.h >@@ -147,12 +147,15 @@ END_RELOC_NUMBERS (R_RISCV_max) > enum > { > /* 0-3 are generic. */ >+ /* Standard. */ > Tag_RISCV_stack_align = 4, > Tag_RISCV_arch = 5, > Tag_RISCV_unaligned_access = 6, > Tag_RISCV_priv_spec = 8, > Tag_RISCV_priv_spec_minor = 10, >- Tag_RISCV_priv_spec_revision = 12 >+ Tag_RISCV_priv_spec_revision = 12, >+ /* Non-standard. */ >+ Tag_RISCV_uleb128_zero_addend = 32768, > }; > > #endif /* _ELF_RISCV_H */ >-- >2.39.3 (Apple Git-145) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 31179
:
15267
| 15270