Skip to content

_GLOBAL_OFFSET_TABLE_ symbol is not emitted for RISCV target #1200

@deepakshirkem

Description

@deepakshirkem

ELD does not emit GLOBAL_OFFSET_TABLE symbol for RISCV targets. This symbol is required for enabling GOT-relative addressing.

Reproducer:

cat >1.c <<\EOF
extern int _GLOBAL_OFFSET_TABLE_;
int *v = &_GLOBAL_OFFSET_TABLE_;
int a;
int foo() { return a; }
EOF

clang -o 1.o -target riscv64 1.c -c -ffunction-sections -fPIC
ld.eld -o 1.eld.out 1.o -mtriple riscv64-unknown-elf

Error:

Error: 1.o(.data+0x0): undefined reference to `_GLOBAL_OFFSET_TABLE_'
Fatal: Linking had errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions