Bug 539941 - Please help to support R_X86_64_32S in elf_relocate()
Summary: Please help to support R_X86_64_32S in elf_relocate()
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.6   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 1.7   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-09 01:09 EDT by Lihua Zhao CLA
Modified: 2021-06-25 16:24 EDT (History)
1 user (show)

See Also:


Attachments
The ELF of test case (7.16 KB, application/octet-stream)
2018-10-09 01:11 EDT, Lihua Zhao CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lihua Zhao CLA 2018-10-09 01:09:29 EDT
Hi,

The new llvm compiler generate R_X86_64_32S type relocation information which couldn't be handled by current TCF open source code, so please help to add the support of R_X86_64_32S in elf_relocate() (/agent/machine/x86_64/tcf/dwarfreloc-mdep.h). The R_X86_64_32S type relocation information is as below:

readelf -r dkm_itl.out | grep R_X86_64_32S :

00000000000c 001e0000000b R_X86_64_32S 00000000000000e8 __init_array_start + 0
000000000017 001d0000000b R_X86_64_32S 00000000000000e8 __init_array_end + 0
000000000062 001b0000000b R_X86_64_32S 00000000000000e8 __fini_array_end + 0
000000000071 001c0000000b R_X86_64_32S 00000000000000e8 __fini_array_start + 0
0000000000bb 00010000000b R_X86_64_32S 0000000000000000 .text + d3


Thanks
Comment 1 Lihua Zhao CLA 2018-10-09 01:11:45 EDT
Created attachment 276177 [details]
The ELF of test case
Comment 2 Lihua Zhao CLA 2018-10-09 06:01:26 EDT
Our PPC64 also use R_PPC64_REL32 relocation type, which isn't supported by ageng/machine/ppc64/tcf/dwarfreloc-mdep.h

readelf -r dkmppc.out | grep R_PPC64_REL32
00000000001c  00010000001a R_PPC64_REL32     0000000000000000 .text + 0
00000000003c  00010000001a R_PPC64_REL32     0000000000000000 .text + 8c
000000000074  00010000001a R_PPC64_REL32     0000000000000000 .text + 118
Comment 3 Sanimir Agovic CLA 2018-10-18 15:25:36 EDT
The patch below works for me

diff --git a/agent/machine/x86_64/tcf/dwarfreloc-mdep.h b/agent/machine/x86_64/tcf/dwarfreloc-mdep.h
index 4f09257f..ac50a7e3 100644
--- a/agent/machine/x86_64/tcf/dwarfreloc-mdep.h
+++ b/agent/machine/x86_64/tcf/dwarfreloc-mdep.h
@@ -21,6 +21,7 @@
 #define R_X86_64_64    1
 #define R_X86_64_PC32  2
 #define R_X86_64_32    10
+#define R_X86_64_32S   11
 
 static void elf_relocate(void) {
     if (relocs->type == SHT_REL && reloc_type != R_X86_64_NONE) {
@@ -48,6 +49,7 @@ static void elf_relocate(void) {
         *destination_section = NULL;
         break;
     case R_X86_64_32:
+    case R_X86_64_32S:
         if (data_size < 4) str_exception(ERR_INV_FORMAT, "Invalid relocation record");
         *(U4_T *)data_buf = (U4_T)(sym_value + reloc_addend);
         break;
Comment 4 Eugene Tarassov CLA 2018-10-19 12:31:45 EDT
Fixed.
Thanks!