Skip to content

Commit

Permalink
Apply Yimin Gu's fixes to elf2flt to allow riscv 32 to use the same
Browse files Browse the repository at this point in the history
relocation mechansims as riscv 64.

Original copy was passed around the buildroot list, but, it would
be helpful for this to be upstream.

You can see the original patch here:

5330503

It looks like it was stomped in some merge?
  • Loading branch information
cnlohr committed Nov 27, 2023
1 parent 679c94a commit 20f8029
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions elf2flt.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const char *elf2flt_progname;
#include <elf/v850.h>
#elif defined(TARGET_xtensa)
#include <elf/xtensa.h>
#elif defined(TARGET_riscv64)
#elif defined(TARGET_riscv64) || defined(TARGET_riscv32)
#include <elf/riscv.h>
#endif

Expand Down Expand Up @@ -127,6 +127,8 @@ const char *elf2flt_progname;
#define ARCH "xtensa"
#elif defined(TARGET_riscv64)
#define ARCH "riscv64"
#elif defined(TARGET_riscv32)
#define ARCH "riscv32"
#else
#error "Don't know how to support your CPU architecture??"
#endif
Expand Down Expand Up @@ -822,7 +824,7 @@ output_relocs (
goto good_32bit_resolved_reloc_update_text;
default:
goto bad_resolved_reloc;
#elif defined(TARGET_riscv64)
#elif defined(TARGET_riscv64) || defined(TARGET_riscv32)
case R_RISCV_NONE:
case R_RISCV_32_PCREL:
case R_RISCV_ADD8:
Expand Down
2 changes: 1 addition & 1 deletion ld-elf2flt.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static int do_final_link(void)
/* riscv adds a global pointer symbol to the linker file with the
"RISCV_GP:" prefix. Remove the prefix for riscv64 architecture and
the entire line for other architectures. */
if (streq(TARGET_CPU, "riscv64"))
if (streq(TARGET_CPU, "riscv64") || streq(TARGET_CPU, "riscv32"))
append_sed(&sed, "^RISCV_GP:", "");
else
append_sed(&sed, "^RISCV_GP:", NULL);
Expand Down

0 comments on commit 20f8029

Please sign in to comment.