forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from unicornx/riscv64_109.0.5414.87_dev_clang
merge riscv64_109.0.5414.87_dev_clang into riscv64_109.0.5414.87_dev
- Loading branch information
Showing
4 changed files
with
243 additions
and
2 deletions.
There are no files selected for viewing
163 changes: 163 additions & 0 deletions
163
third_party/llvm-patches/0001-applied-patch-D145474.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
From 881585120dd548eedc17a74b5ff05b528c7c5d68 Mon Sep 17 00:00:00 2001 | ||
From: Wang Chen <[email protected]> | ||
Date: Sat, 11 Mar 2023 19:31:42 +0800 | ||
Subject: [PATCH] applied patch D145474 | ||
|
||
Signed-off-by: Wang Chen <[email protected]> | ||
--- | ||
.../RISCV/MCTargetDesc/RISCVELFStreamer.cpp | 10 ++ | ||
llvm/test/MC/RISCV/riscv64-64b-pcrel.s | 111 +++++++++++------- | ||
2 files changed, 81 insertions(+), 40 deletions(-) | ||
|
||
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp | ||
index c63488bb4d34..11b158c5e55f 100644 | ||
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp | ||
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp | ||
@@ -239,6 +239,16 @@ class RISCVELFStreamer : public MCELFStreamer { | ||
if (B.isInSection() && B.getSection().getKind().isText()) | ||
return true; | ||
|
||
+ // If A is undefined and B is defined, we should emit ADD/SUB for A-B. | ||
+ // Unfortunately, A may be defined later, but this requiresFixups call has to | ||
+ // eagerly make a decision. For now, emit ADD/SUB unless A is .L*. This | ||
+ // heuristic handles many temporary label differences for .debug_* and | ||
+ // .apple_types sections. | ||
+ // | ||
+ // TODO Implement delayed relocation decision. | ||
+ if (!A.isInSection() && !A.isTemporary() && B.isInSection()) | ||
+ return true; | ||
+ | ||
// Support cross-section symbolic differences ... | ||
return A.isInSection() && B.isInSection() && | ||
A.getSection().getName() != B.getSection().getName(); | ||
diff --git a/llvm/test/MC/RISCV/riscv64-64b-pcrel.s b/llvm/test/MC/RISCV/riscv64-64b-pcrel.s | ||
index 5f5870ee7331..951c882f03ca 100644 | ||
--- a/llvm/test/MC/RISCV/riscv64-64b-pcrel.s | ||
+++ b/llvm/test/MC/RISCV/riscv64-64b-pcrel.s | ||
@@ -1,51 +1,82 @@ | ||
# RUN: llvm-mc -triple riscv64-unknown-linux-gnu -filetype obj -o - %s \ | ||
# RUN: | llvm-readobj -r - | FileCheck %s | ||
# RUN: not llvm-mc -triple riscv64-unknown-linux-gnu -filetype obj --defsym ERR=1 -o /dev/null %s 2>&1 \ | ||
-# RUN: | FileCheck %s --check-prefix CHECK-ERROR | ||
+# RUN: | FileCheck %s --check-prefix=ERROR | ||
|
||
-# CHECK: Relocations [ | ||
-# CHECK: .relasx { | ||
-# CHECK-NEXT: 0x0 R_RISCV_ADD64 y 0x0 | ||
-# CHECK-NEXT: 0x0 R_RISCV_SUB64 x 0x0 | ||
-# CHECK: } | ||
-# CHECK: .relasy { | ||
-# CHECK-NEXT: 0x0 R_RISCV_ADD64 x 0x0 | ||
-# CHECK-NEXT: 0x0 R_RISCV_SUB64 y 0x0 | ||
-# CHECK: } | ||
-# CHECK: .relasa { | ||
-# CHECK-NEXT: 0x0 R_RISCV_ADD64 a 0x0 | ||
-# CHECK-NEXT: 0x0 R_RISCV_SUB64 z 0x0 | ||
-# CHECK: } | ||
+# CHECK: Relocations [ | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.note { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 extern 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 note 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.rodata { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 extern 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 rodata 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.alloc_w { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 extern 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 w 0x0 | ||
+# CHECK-NEXT: 0x8 R_RISCV_ADD64 w 0x0 | ||
+# CHECK-NEXT: 0x8 R_RISCV_SUB64 extern 0x0 | ||
+# CHECK-NEXT: 0x10 R_RISCV_ADD32 x 0x0 | ||
+# CHECK-NEXT: 0x10 R_RISCV_SUB32 w 0x0 | ||
+# CHECK-NEXT: 0x14 R_RISCV_ADD32 w1 0x0 | ||
+# CHECK-NEXT: 0x14 R_RISCV_SUB32 w 0x0 | ||
+# CHECK-NEXT: 0x18 R_RISCV_ADD32 .L.str 0x0 | ||
+# CHECK-NEXT: 0x18 R_RISCV_SUB32 w 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.alloc_x { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 y 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 x 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.alloc_y { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 x 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 y 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.nonalloc_w { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 extern 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 nw 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.nonalloc_x { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 ny 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 nx 0x0 | ||
+# CHECK-NEXT: } | ||
+# CHECK-NEXT: Section ({{.*}}) .rela.nonalloc_y { | ||
+# CHECK-NEXT: 0x0 R_RISCV_ADD64 nx 0x0 | ||
+# CHECK-NEXT: 0x0 R_RISCV_SUB64 ny 0x0 | ||
+# CHECK-NEXT: } | ||
# CHECK-NEXT: ] | ||
|
||
- .section sx,"aw",@progbits | ||
-x: | ||
- .quad y-x | ||
+.section .note,"a",@note; note: | ||
+.quad extern-note | ||
+.section .rodata,"a",@progbits; rodata: | ||
+.quad extern-rodata | ||
|
||
- .section sy,"aw",@progbits | ||
-y: | ||
- .quad x-y | ||
+.section .alloc_w,"aw",@progbits; w: | ||
+.quad extern-w # extern is undefined | ||
+.quad w-extern | ||
+.long x-w # A is later defined in another section | ||
+.long w1-w # A is later defined in the same section | ||
+.long .L.str-w # A is temporary | ||
+w1: | ||
|
||
- .section sz | ||
-z: | ||
-.ifdef ERR | ||
- .quad z-a | ||
+.section .alloc_x,"aw",@progbits; x: | ||
+.quad y-x | ||
+.section .alloc_y,"aw",@progbits; y: | ||
+.quad x-y | ||
|
||
-# CHECK-ERROR: Cannot represent a difference across sections | ||
-# CHECK-ERROR: .quad z-a | ||
-# CHECK-ERROR: ^ | ||
-.else | ||
- .quad 0 | ||
+.section .nonalloc_w; nw: | ||
+.quad extern-nw | ||
+.ifdef ERR | ||
+# ERROR: :[[#@LINE+1]]:7: error: symbol 'extern' can not be undefined in a subtraction expression | ||
+.quad nw-extern | ||
.endif | ||
+.section .nonalloc_x; nx: | ||
+.quad ny-nx | ||
+.section .nonalloc_y; ny: | ||
+.quad nx-ny | ||
|
||
- .section sa | ||
-a: | ||
- .quad a-z | ||
- | ||
-## .apple_names/.apple_types are fixed-size and do not need fixups. | ||
-## llvm-dwarfdump --apple-names does not process R_RISCV_{ADD,SUB}32 in them. | ||
-## See llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll | ||
- .section .apple_types | ||
- .word 0 | ||
- .word .Ltypes0-.apple_types | ||
-.Ltypes0: | ||
+## -gdwarf-aranges generated assembly expects no relocation. | ||
+## Otherwise, a .Lsec_end0 symbol (defined at the end of .rodata.str1.1) | ||
+## will be rejected by linkers. | ||
+.section .rodata.str1.1,"aMS",@progbits,1 | ||
+.L.str: | ||
\ No newline at end of file | ||
-- | ||
2.25.1 | ||
|
60 changes: 60 additions & 0 deletions
60
third_party/llvm-patches/Enable-targeting-riscv64-linux-android.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
From 91520467c83d3265e618910f4daed657f93a8430 Mon Sep 17 00:00:00 2001 | ||
From: Colin Cross <[email protected]> | ||
Date: Thu, 13 Oct 2022 13:19:19 -0700 | ||
Subject: [PATCH] Enable targeting riscv64-linux-android | ||
|
||
Add riscv64-linux-android to Linux::getMultiarchTriple, add | ||
__get_tls for riscv64-linux-android sanitizers, and add RISCV64 | ||
to the list of Android fuzzer targets. | ||
|
||
Test: build.py | ||
Change-Id: I0fdf55125d22d1d3aab9d2199838f25562ffd8a0 | ||
--- | ||
clang/lib/Driver/ToolChains/Linux.cpp | 2 ++ | ||
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake | 2 +- | ||
compiler-rt/lib/sanitizer_common/sanitizer_linux.h | 3 +++ | ||
3 files changed, 6 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp | ||
index ceb1a982c3a4..ed8079353ea4 100644 | ||
--- a/clang/lib/Driver/ToolChains/Linux.cpp | ||
+++ b/clang/lib/Driver/ToolChains/Linux.cpp | ||
@@ -125,6 +125,8 @@ std::string Linux::getMultiarchTriple(const Driver &D, | ||
case llvm::Triple::ppc64le: | ||
return "powerpc64le-linux-gnu"; | ||
case llvm::Triple::riscv64: | ||
+ if (IsAndroid) | ||
+ return "riscv64-linux-android"; | ||
return "riscv64-linux-gnu"; | ||
case llvm::Triple::sparc: | ||
return "sparc-linux-gnu"; | ||
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake | ||
index a1da35b0ac4b..68a386019070 100644 | ||
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake | ||
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake | ||
@@ -42,7 +42,7 @@ if(OS_NAME MATCHES "Linux") | ||
elseif (OS_NAME MATCHES "Windows") | ||
set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64}) | ||
elseif(OS_NAME MATCHES "Android") | ||
- set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}) | ||
+ set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}) | ||
else() | ||
set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64}) | ||
endif() | ||
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h | ||
index 761c57d1b8eb..13c359c7e3a3 100644 | ||
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h | ||
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h | ||
@@ -152,6 +152,9 @@ inline void ReleaseMemoryPagesToOSAndZeroFill(uptr beg, uptr end) { | ||
"rdhwr %0,$29\n" \ | ||
".set pop\n" : "=r"(__v)); \ | ||
__v; }) | ||
+#elif defined (__riscv) | ||
+# define __get_tls() \ | ||
+ ({ void** __v; __asm__("mv %0, tp" : "=r"(__v)); __v; }) | ||
#elif defined(__i386__) | ||
# define __get_tls() \ | ||
({ void** __v; __asm__("movl %%gs:0, %0" : "=r"(__v)); __v; }) | ||
-- | ||
2.38.0.135.g90850a2211-goog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters