ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.73k stars 267 forks source link

Handle `.relr.dyn` section #1626

Closed Coekjan closed 2 months ago

Coekjan commented 2 months ago

Fixes #1623

Reference: https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dynamic-link.h;h=83d834ecaf609082506d161b9744a2b476469b5e;hb=HEAD#l153

Coekjan commented 2 months ago

Because RELR is a new feature introduced since glibc 2.36, current ubuntu-20.04 runners may not support this feature, resulting in these compilation errors. I think we could have 2 options:

  1. do something to the runner (e.g. upgrade it), and let it support RELR:
    • benefit: users who runs new programs (using RELR) will be happy.
    • drawback: to let the runner support RELR may need some engineering efforts on CI.
  2. do something to the code (e.g. conditionally compile the part about RELR):
    • benefit: no need to adapt CI.
    • drawback: users' x64 apps (using RELR) can not run on these prebuilt box64 binaries.
rajdakin commented 2 months ago
  1. You can also conditionally copy/paste the new definitions in a header (something like:
    #ifndef DT_RELR
    typedef struct Elf64_Relr {
    (omitted)
    } Elf64_Relr;
    #define DT_RELR (omitted)
    #define DT_RELRSZ (omitted)
    #define DT_RELRENT (omitted)
    ...
    #endif

    somewhere in the elfloader.h file)

    • benefit: users who run newer programs (which use relr) will be happy
    • also benefit: no need to adapt the CI
Coekjan commented 2 months ago

You can also conditionally copy/paste the new definitions in a header

I think this is good for now, and in the future if glibc 2.36 is widely used, we can remove these copied-pasted definitions.