Skip to content

Commit

Permalink
Merge pull request #45 from michalbiesek/feat-add-riscv-support
Browse files Browse the repository at this point in the history
Add riscv support
  • Loading branch information
kubo authored Jun 1, 2023
2 parents d9d02dd + 65df541 commit 290aac6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ jobs:
- uses: actions/checkout@v2
- name: Install packages
run: |
sudo apt install -y gcc-multilib libc6-dbg valgrind
sudo apt update
sudo apt install -y gcc-multilib libc6-dbg valgrind
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y libc6-dbg:i386
sudo apt install -y libc6-dbg:i386 libgcc-s1:i386
- name: x86_64 without optimization
run: |
make relro_pie_tests
Expand Down Expand Up @@ -72,7 +73,7 @@ jobs:
./uclibc-test.sh i686
tests_on_qemu:
name: Tests on Qemu (arm, armhf, arm64, ppc and ppc64le)
name: Tests on Qemu (arm, armhf, arm64, ppc, ppc64le and riscv64)
if: github.event.inputs.tests_on_qemu == 'true' || github.event.inputs.tests_on_qemu == ''
runs-on: ubuntu-latest
defaults:
Expand All @@ -82,7 +83,8 @@ jobs:
- uses: actions/checkout@v2
- name: Install packages
run: |
sudo apt install -y qemu-user gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-powerpc-linux-gnu gcc-powerpc64le-linux-gnu libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-powerpc-cross libc6-dev-armel-cross libc6-dev-arm64-cross
sudo apt update
sudo apt install -y qemu-user gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-powerpc-linux-gnu gcc-powerpc64le-linux-gnu gcc-riscv64-linux-gnu libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-powerpc-cross libc6-dev-armel-cross libc6-dev-arm64-cross
- name: arm-linux-gnueabi without optimization
run: |
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabi
Expand All @@ -98,6 +100,9 @@ jobs:
- name: powerpc64le-linux-gnu without optimization
run: |
make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le
- name: riscv64-linux-gnu without optimization
run: |
make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64
- name: set OPT_CLFAGS
run: |
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
Expand All @@ -116,6 +121,9 @@ jobs:
- name: powerpc64le-linux-gnu with optimization
run: |
make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le
- name: riscv64-linux-gnu with optimization
run: |
make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64
tests_on_macos:
name: Tests on macOS
Expand Down
15 changes: 15 additions & 0 deletions plthook_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
#elif defined __powerpc__
#define R_JUMP_SLOT R_PPC_JMP_SLOT
#define R_GLOBAL_DATA R_PPC_GLOB_DAT
#elif defined __riscv
#define R_JUMP_SLOT R_RISCV_JUMP_SLOT
#if __riscv_xlen == 32
#define R_GLOBAL_DATA R_RISCV_32
#elif __riscv_xlen == 64
#define R_GLOBAL_DATA R_RISCV_64
#else
#error unsupported RISCV implementation
#endif
#elif 0 /* disabled because not tested */ && (defined __sparcv9 || defined __sparc_v9__)
#define R_JUMP_SLOT R_SPARC_JMP_SLOT
#elif 0 /* disabled because not tested */ && (defined __sparc || defined __sparc__)
Expand Down Expand Up @@ -553,6 +562,12 @@ static int plthook_open_real(plthook_t **plthook_out, struct link_map *lmap)

#if defined __linux__
plthook.plt_addr_base = (char*)lmap->l_addr;
#if defined __riscv
const Elf_Ehdr *ehdr = (const Elf_Ehdr*)lmap->l_addr;
if (ehdr->e_type == ET_DYN) {
dyn_addr_base = (const char*)lmap->l_addr;
}
#endif
#if defined __ANDROID__ || defined __UCLIBC__
dyn_addr_base = (const char*)lmap->l_addr;
#endif
Expand Down

0 comments on commit 290aac6

Please sign in to comment.