Skip to content

DATA_GOT_TYPE undeclared on non-x86_64 architectures (ppc64, ppc64le, aarch64) #139

@SamHerts

Description

@SamHerts

Building Spindle on non-x86_64 architectures (aarch64, ppc64, ppc64le) fails with a compile error

writablegot.c:124:50: error: 'DATA_GOT_TYPE' undeclared (first use in this function)
  124 |          if (ELF64_R_TYPE(datarels[j].r_info) != DATA_GOT_TYPE)
      |                                                  ^~~~~~~~~~~~~

Root cause:

DATA_GOT_TYPE is defined in the architecture guard block in

#if defined(arch_x86_64)
#define DEFAULT_RELENTSZ 24
#define EXTRA_GOT_ENTRIES 3
#define DATA_GOT_TYPE R_X86_64_GLOB_DAT

but not defined for other architectures

#elif defined(arch_ppc64) || defined(arch_ppc64le)
#define DEFAULT_RELENTSZ 24
#define EXTRA_GOT_ENTRIES 2

#elif defined(arch_aarch64)
#define DEFAULT_RELENTSZ 24
#define EXTRA_GOT_ENTRIES 4

The macro is then used unconditionally at line 124 regardless of architecture, causing the build to
fail on any architecture other than x86_64.

unsigned long target = datarels[j].r_offset + map->l_addr;
if (ELF64_R_TYPE(datarels[j].r_info) != DATA_GOT_TYPE)
continue;

Expected behavior

Spindle should build successfully on all supported architectures (x86_64, ppc64, aarch64).

Suggested fix

Add the appropriate ELF GLOB_DAT relocation type constant for each architecture in the guard block. The
correct constant names should be confirmed from <elf.h> on each target platform

Arch VAR_NAME Source
PPC64 R_PPC64_GLOB_DAT elf.h L2710
Aarch64 R_AARCH64_GLOB_DAT elf.h L3026

Environment

  • Spindle: devel branch (commit 4174224)
  • OS: Rocky Linux 10.1 (Red Quartz)
  • Compiler: GCC 15 (gnu15 toolchain)
  • Affected file: src/client/auditclient/writablegot.c:124

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions