Skip to content

Commit b374b2c

Browse files
committed
Replace hex number representation in ASM files
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 dotnet#22810), with some modifications to compile, which was about adding compatiblity with GCC 5.
1 parent 12fd9b7 commit b374b2c

File tree

6 files changed

+74
-74
lines changed

6 files changed

+74
-74
lines changed

src/debug/ee/amd64/dbghelpers.S

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, UnhandledExceptionHandlerUnix
2929
//
3030
// epilogue
3131
//
32-
add rsp, 20h
32+
add rsp, 0x20
3333
TAILJMP_RAX
3434
NESTED_END FuncEvalHijack, _TEXT
3535

@@ -65,14 +65,14 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
6565
// its arguments on the stack. In x64, it gets its arguments in
6666
// registers (set up for us by DacDbiInterfaceImpl::Hijack),
6767
// and this stack space may be reused.
68-
mov rax, [rsp + 20h]
68+
mov rax, [rsp + 0x20]
6969
mov [rsp], rax
70-
mov rax, [rsp + 28h]
71-
mov [rsp + 8h], rax
72-
mov rax, [rsp + 30h]
73-
mov [rsp + 10h], rax
74-
mov rax, [rsp + 38h]
75-
mov [rsp + 18h], rax
70+
mov rax, [rsp + 0x28]
71+
mov [rsp + 0x8], rax
72+
mov rax, [rsp + 0x30]
73+
mov [rsp + 0x10], rax
74+
mov rax, [rsp + 0x38]
75+
mov [rsp + 0x18], rax
7676
7777
// DD Hijack primitive already set the stack. So just make the call now.
7878
call C_FUNC(ExceptionHijackWorker)
@@ -93,7 +93,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
9393
//
9494
// epilogue
9595
//
96-
add rsp, 20h
96+
add rsp, 0x20
9797
TAILJMP_RAX
9898

9999
// Put a label here to tell the debugger where the end of this function is.

src/pal/inc/unixasmmacros.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#define INVALIDGCVALUE 0CCCCCCCDh
5+
#define INVALIDGCVALUE 0xCCCCCCCD
66

77
#if defined(__APPLE__)
88
#define C_FUNC(name) _##name

src/vm/amd64/jithelpers_fast.S

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT
8181
// Update the write watch table if necessary
8282
mov rax, rdi
8383
movabs r10, 0xF0F0F0F0F0F0F0F0
84-
shr rax, 0Ch // SoftwareWriteWatch::AddressToTableByteIndexShift
84+
shr rax, 0xC // SoftwareWriteWatch::AddressToTableByteIndexShift
8585
NOP_2_BYTE // padding for alignment of constant
8686
movabs r11, 0xF0F0F0F0F0F0F0F0
8787
add rax, r10
88-
cmp byte ptr [rax], 0h
88+
cmp byte ptr [rax], 0x0
8989
.byte 0x75, 0x06
9090
// jne CheckCardTable
91-
mov byte ptr [rax], 0FFh
91+
mov byte ptr [rax], 0xFF
9292

9393
NOP_3_BYTE // padding for alignment of constant
9494

@@ -112,27 +112,27 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT
112112

113113
// Touch the card table entry, if not already dirty.
114114
shr rdi, 0x0B
115-
cmp byte ptr [rdi + rax], 0FFh
115+
cmp byte ptr [rdi + rax], 0xFF
116116
.byte 0x75, 0x02
117117
// jne UpdateCardTable
118118
REPRET
119119

120120
UpdateCardTable:
121-
mov byte ptr [rdi + rax], 0FFh
121+
mov byte ptr [rdi + rax], 0xFF
122122

123123
#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
124124
NOP_2_BYTE // padding for alignment of constant
125125
shr rdi, 0x0A
126126

127127
movabs rax, 0xF0F0F0F0F0F0F0F0
128-
cmp byte ptr [rdi + rax], 0FFh
128+
cmp byte ptr [rdi + rax], 0xFF
129129

130130
.byte 0x75, 0x02
131131
// jne UpdateCardBundle_WriteWatch_PostGrow64
132132
REPRET
133133

134134
UpdateCardBundle_WriteWatch_PostGrow64:
135-
mov byte ptr [rdi + rax], 0FFh
135+
mov byte ptr [rdi + rax], 0xFF
136136
#endif
137137

138138
ret
@@ -312,15 +312,15 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
312312
#ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
313313
// Update the write watch table if necessary
314314
PREPARE_EXTERNAL_VAR g_sw_ww_enabled_for_gc_heap, rax
315-
cmp byte ptr [rax], 0h
315+
cmp byte ptr [rax], 0x0
316316
je CheckCardTable_ByRefWriteBarrier
317317
mov rax, rdi
318-
shr rax, 0Ch // SoftwareWriteWatch::AddressToTableByteIndexShift
318+
shr rax, 0xC // SoftwareWriteWatch::AddressToTableByteIndexShift
319319
PREPARE_EXTERNAL_VAR g_sw_ww_table, r10
320320
add rax, qword ptr [r10]
321-
cmp byte ptr [rax], 0h
321+
cmp byte ptr [rax], 0x0
322322
jne CheckCardTable_ByRefWriteBarrier
323-
mov byte ptr [rax], 0FFh
323+
mov byte ptr [rax], 0xFF
324324
#endif
325325

326326
CheckCardTable_ByRefWriteBarrier:
@@ -334,8 +334,8 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
334334

335335
// move current rdi value into rcx and then increment the pointers
336336
mov rcx, rdi
337-
add rsi, 8h
338-
add rdi, 8h
337+
add rsi, 0x8
338+
add rdi, 0x8
339339

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

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

350350
jne UpdateCardTable_ByRefWriteBarrier
351351
REPRET
352352

353353
UpdateCardTable_ByRefWriteBarrier:
354-
mov byte ptr [rcx + rax], 0FFh
354+
mov byte ptr [rcx + rax], 0xFF
355355

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

363363
// Check if this bundle byte is dirty
364-
cmp byte ptr [rcx], 0FFh
364+
cmp byte ptr [rcx], 0xFF
365365

366366
jne UpdateCardBundle_ByRefWriteBarrier
367367
REPRET
368368

369369
UpdateCardBundle_ByRefWriteBarrier:
370-
mov byte ptr [rcx], 0FFh
370+
mov byte ptr [rcx], 0xFF
371371
#endif
372372

373373
ret
@@ -383,8 +383,8 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
383383
#endif
384384
Exit_ByRefWriteBarrier:
385385
// Increment the pointers before leaving
386-
add rdi, 8h
387-
add rsi, 8h
386+
add rdi, 0x8
387+
add rsi, 0x8
388388
ret
389389
LEAF_END JIT_ByRefWriteBarrier, _TEXT
390390

0 commit comments

Comments
 (0)