Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Replace hex number representation in ASM files
Browse files Browse the repository at this point in the history
This commit fixes coreclr to build in newer versions of llvm (tested
with llvm 8 on Fedora 30).

These recent versions of llvm (as well as GCC) do not accept values like
"20h" as valid integer literals:

    src/debug/ee/amd64/dbghelpers.S:32:21: error: unknown token in expression
            add rsp, 20h
                        ^

This was reported as a bug to llvm upstream and they explicitly rejected
supporting these literals: https://reviews.llvm.org/D59810

This is partial backport of cbd672e
(PR #22810), with some modifications to compile, which was about adding
compatibility with GCC 5.
  • Loading branch information
omajid committed Aug 12, 2019
1 parent 12fd9b7 commit 3366bd7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 74 deletions.
18 changes: 9 additions & 9 deletions src/debug/ee/amd64/dbghelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, UnhandledExceptionHandlerUnix
//
// epilogue
//
add rsp, 20h
add rsp, 0x20
TAILJMP_RAX
NESTED_END FuncEvalHijack, _TEXT

Expand Down Expand Up @@ -65,14 +65,14 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
// its arguments on the stack. In x64, it gets its arguments in
// registers (set up for us by DacDbiInterfaceImpl::Hijack),
// and this stack space may be reused.
mov rax, [rsp + 20h]
mov rax, [rsp + 0x20]
mov [rsp], rax
mov rax, [rsp + 28h]
mov [rsp + 8h], rax
mov rax, [rsp + 30h]
mov [rsp + 10h], rax
mov rax, [rsp + 38h]
mov [rsp + 18h], rax
mov rax, [rsp + 0x28]
mov [rsp + 0x8], rax
mov rax, [rsp + 0x30]
mov [rsp + 0x10], rax
mov rax, [rsp + 0x38]
mov [rsp + 0x18], rax

// DD Hijack primitive already set the stack. So just make the call now.
call C_FUNC(ExceptionHijackWorker)
Expand All @@ -93,7 +93,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
//
// epilogue
//
add rsp, 20h
add rsp, 0x20
TAILJMP_RAX

// Put a label here to tell the debugger where the end of this function is.
Expand Down
2 changes: 1 addition & 1 deletion src/pal/inc/unixasmmacros.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#define INVALIDGCVALUE 0CCCCCCCDh
#define INVALIDGCVALUE 0xCCCCCCCD

#if defined(__APPLE__)
#define C_FUNC(name) _##name
Expand Down
38 changes: 19 additions & 19 deletions src/vm/amd64/jithelpers_fast.S
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT
// Update the write watch table if necessary
mov rax, rdi
movabs r10, 0xF0F0F0F0F0F0F0F0
shr rax, 0Ch // SoftwareWriteWatch::AddressToTableByteIndexShift
shr rax, 0xC // SoftwareWriteWatch::AddressToTableByteIndexShift
NOP_2_BYTE // padding for alignment of constant
movabs r11, 0xF0F0F0F0F0F0F0F0
add rax, r10
cmp byte ptr [rax], 0h
cmp byte ptr [rax], 0x0
.byte 0x75, 0x06
// jne CheckCardTable
mov byte ptr [rax], 0FFh
mov byte ptr [rax], 0xFF

NOP_3_BYTE // padding for alignment of constant

Expand All @@ -112,27 +112,27 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT

// Touch the card table entry, if not already dirty.
shr rdi, 0x0B
cmp byte ptr [rdi + rax], 0FFh
cmp byte ptr [rdi + rax], 0xFF
.byte 0x75, 0x02
// jne UpdateCardTable
REPRET

UpdateCardTable:
mov byte ptr [rdi + rax], 0FFh
mov byte ptr [rdi + rax], 0xFF

#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
NOP_2_BYTE // padding for alignment of constant
shr rdi, 0x0A

movabs rax, 0xF0F0F0F0F0F0F0F0
cmp byte ptr [rdi + rax], 0FFh
cmp byte ptr [rdi + rax], 0xFF

.byte 0x75, 0x02
// jne UpdateCardBundle_WriteWatch_PostGrow64
REPRET

UpdateCardBundle_WriteWatch_PostGrow64:
mov byte ptr [rdi + rax], 0FFh
mov byte ptr [rdi + rax], 0xFF
#endif

ret
Expand Down Expand Up @@ -312,15 +312,15 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
#ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
// Update the write watch table if necessary
PREPARE_EXTERNAL_VAR g_sw_ww_enabled_for_gc_heap, rax
cmp byte ptr [rax], 0h
cmp byte ptr [rax], 0x0
je CheckCardTable_ByRefWriteBarrier
mov rax, rdi
shr rax, 0Ch // SoftwareWriteWatch::AddressToTableByteIndexShift
shr rax, 0xC // SoftwareWriteWatch::AddressToTableByteIndexShift
PREPARE_EXTERNAL_VAR g_sw_ww_table, r10
add rax, qword ptr [r10]
cmp byte ptr [rax], 0h
cmp byte ptr [rax], 0x0
jne CheckCardTable_ByRefWriteBarrier
mov byte ptr [rax], 0FFh
mov byte ptr [rax], 0xFF
#endif

CheckCardTable_ByRefWriteBarrier:
Expand All @@ -334,8 +334,8 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT

// move current rdi value into rcx and then increment the pointers
mov rcx, rdi
add rsi, 8h
add rdi, 8h
add rsi, 0x8
add rdi, 0x8

// Check if we need to update the card table
// Calc pCardByte
Expand All @@ -345,13 +345,13 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
mov rax, [rax]

// Check if this card is dirty
cmp byte ptr [rcx + rax], 0FFh
cmp byte ptr [rcx + rax], 0xFF

jne UpdateCardTable_ByRefWriteBarrier
REPRET

UpdateCardTable_ByRefWriteBarrier:
mov byte ptr [rcx + rax], 0FFh
mov byte ptr [rcx + rax], 0xFF

#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
// Shift rcx by 0x0A more to get the card bundle byte (we shifted by 0x0B already)
Expand All @@ -361,13 +361,13 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
add rcx, [rax]

// Check if this bundle byte is dirty
cmp byte ptr [rcx], 0FFh
cmp byte ptr [rcx], 0xFF

jne UpdateCardBundle_ByRefWriteBarrier
REPRET

UpdateCardBundle_ByRefWriteBarrier:
mov byte ptr [rcx], 0FFh
mov byte ptr [rcx], 0xFF
#endif

ret
Expand All @@ -383,8 +383,8 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
#endif
Exit_ByRefWriteBarrier:
// Increment the pointers before leaving
add rdi, 8h
add rsi, 8h
add rdi, 0x8
add rsi, 0x8
ret
LEAF_END JIT_ByRefWriteBarrier, _TEXT

Expand Down
Loading

0 comments on commit 3366bd7

Please sign in to comment.