From ca572d77272ed13970104c57901bc6be1c0b2f76 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 9 Mar 2021 20:34:50 -0800 Subject: [PATCH] [JITLink] Add support for STT_NOTYPE symbols to ELF/x86-64. --- lib/ExecutionEngine/JITLink/ELF_x86_64.cpp | 4 ++-- .../JITLink/X86/ELF_x86-64_relocations.s | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp index 5a0c8976cf5..f81e67421c1 100644 --- a/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp +++ b/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp @@ -596,8 +596,8 @@ private: } if (SymRef.isDefined() && - (Type == ELF::STT_FUNC || Type == ELF::STT_OBJECT || - Type == ELF::STT_SECTION)) { + (Type == ELF::STT_NOTYPE || Type == ELF::STT_FUNC || + Type == ELF::STT_OBJECT || Type == ELF::STT_SECTION)) { auto DefinedSection = Obj.getSection(SymRef.st_shndx); if (!DefinedSection) diff --git a/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s b/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s index eada709cfe3..c2039bd6426 100644 --- a/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s +++ b/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s @@ -106,8 +106,18 @@ test_rex_gotpcrelx: .size test_rex_gotpcrelx, .-test_rex_gotpcrelx - .type named_data,@object +# Test that relocations to anonymous constant pool entries work. + .globl test_anchor_LCPI + .p2align 4, 0x90 + .type test_anchor_LCPI,@function +test_anchor_LCPI: + movq .LCPI0_0(%rip), %rax + + .size test_anchor_LCPI, .-test_anchor_LCPI + .data + + .type named_data,@object .p2align 3 named_data: .quad 42 @@ -124,6 +134,12 @@ bss_variable: .long 0 .size bss_variable, 4 +# Constant pool entry with type STT_NOTYPE. + .section .rodata.cst8,"aM",@progbits,8 + .p2align 3 +.LCPI0_0: + .quad 0x400921fb54442d18 + .ident "clang version 10.0.0-4ubuntu1 " .section ".note.GNU-stack","",@progbits .addrsig