<div dir="ltr">> movk    x0, #:prel_g3:.L.str+4294967296<div><br></div><div>Looks like it's getting tripped up on the relocation.</div><div><br></div><div>Peter - was there any additional work on the prel_g3 relocation when you landed these patches?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 22, 2020 at 1:45 PM Derrick McKee <<a href="mailto:derrick.mckee@gmail.com">derrick.mckee@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Mitch,<br>
<br>
> cat test.c<br>
<br>
#include <stdio.h><br>
<br>
int main(int argc, char** argv) {<br>
    printf("Hello, world!\n");<br>
    return 0;<br>
}<br>
<br>
<br>
> cat test.s<br>
    .text<br>
    .file    "test.c"<br>
    .globl    main                    // -- Begin function main<br>
    .p2align    2<br>
    .type    main,@function<br>
main:                                   // @main<br>
.Lfunc_begin0:<br>
    .file    1 "/home/derrick/tmp" "test.c"<br>
    .loc    1 3 0                   // test.c:3:0<br>
    .cfi_startproc<br>
// %bb.0:<br>
    sub    sp, sp, #48             // =48<br>
    stp    x29, x30, [sp, #32]     // 16-byte Folded Spill<br>
    add    x29, sp, #32            // =32<br>
    .cfi_def_cfa w29, 16<br>
    .cfi_offset w30, -8<br>
    .cfi_offset w29, -16<br>
    adrp    x8, :gottprel:__hwasan_tls<br>
    ldr    x8, [x8, :gottprel_lo12:__hwasan_tls]<br>
    mrs    x9, TPIDR_EL0<br>
    ldr    x8, [x9, x8]<br>
    orr    x8, x8, #0xffffffff<br>
    add    x8, x8, #1              // =1<br>
    sub    x2, x29, #4             // =4<br>
    mov    x9, x8<br>
    bl    __hwasan_check_x2_18_short<br>
    mov    w10, wzr<br>
    stur    w10, [x29, #-4]<br>
    sub    x2, x29, #8             // =8<br>
    mov    x9, x8<br>
    bl    __hwasan_check_x2_18_short<br>
    stur    w0, [x29, #-8]<br>
    add    x2, sp, #16             // =16<br>
    mov    x9, x8<br>
    bl    __hwasan_check_x2_19_short<br>
    str    x1, [sp, #16]<br>
.Ltmp0:<br>
    .loc    1 4 2 prologue_end      // test.c:4:2<br>
    adrp    x0, :pg_hi21_nc:.L.str<br>
    movk    x0, #:prel_g3:.L.str+4294967296<br>
    add    x0, x0, :lo12:.L.str<br>
    str    w10, [sp, #12]          // 4-byte Folded Spill<br>
    bl    printf<br>
    ldr    w10, [sp, #12]          // 4-byte Folded Reload<br>
    str    w0, [sp, #8]            // 4-byte Folded Spill<br>
    .loc    1 5 2                   // test.c:5:2<br>
    mov    w0, w10<br>
    ldp    x29, x30, [sp, #32]     // 16-byte Folded Reload<br>
    add    sp, sp, #48             // =48<br>
    ret<br>
.Ltmp1:<br>
.Lfunc_end0:<br>
    .size    main, .Lfunc_end0-main<br>
    .cfi_endproc<br>
                                        // -- End function<br>
    .section<br>
.text.hwasan.module_ctor,"axG",@progbits,hwasan.module_ctor,comdat<br>
    .p2align    2               // -- Begin function hwasan.module_ctor<br>
    .type    hwasan.module_ctor,@function<br>
hwasan.module_ctor:                     // @hwasan.module_ctor<br>
.Lfunc_begin1:<br>
    .cfi_startproc<br>
// %bb.0:<br>
    str    x30, [sp, #-16]!        // 8-byte Folded Spill<br>
    .cfi_def_cfa_offset 16<br>
    .cfi_offset w30, -16<br>
    bl    __hwasan_init<br>
    ldr    x30, [sp], #16          // 8-byte Folded Reload<br>
    ret<br>
.Lfunc_end1:<br>
    .size    hwasan.module_ctor, .Lfunc_end1-hwasan.module_ctor<br>
    .cfi_endproc<br>
                                        // -- End function<br>
    .section    .init_array.0,"aGw",@init_array,hwasan.module_ctor,comdat<br>
    .p2align    3<br>
    .xword    hwasan.module_ctor<br>
    .hidden    __start_hwasan_globals<br>
    .hidden    __stop_hwasan_globals<br>
    .type    .Lhwasan.note,@object   // @hwasan.note<br>
    .section    .note.hwasan.globals,"aG",@note,hwasan.note,comdat<br>
    .p2align    2<br>
.Lhwasan.note:<br>
    .word    8                       // 0x8<br>
    .word    8                       // 0x8<br>
    .word    3                       // 0x3<br>
    .asciz    "LLVM\000\000\000"<br>
    .word    __start_hwasan_globals-.Lhwasan.note<br>
    .word    __stop_hwasan_globals-.Lhwasan.note<br>
    .size    .Lhwasan.note, 28<br>
<br>
    .type    .Lhwasan.dummy.global,@object // @hwasan.dummy.global<br>
    .section<br>
hwasan_globals,"aGo",@progbits,hwasan.note,comdat,.Lhwasan.note,unique,1<br>
    .p2align    2<br>
.Lhwasan.dummy.global:<br>
    .size    .Lhwasan.dummy.global, 0<br>
<br>
    .type    .L.str.hwasan,@object   // @.str.hwasan<br>
    .section    .rodata,"a",@progbits<br>
    .p2align    4<br>
.L.str.hwasan:<br>
    .asciz    "Hello, world!\n"<br>
    .byte    208<br>
    .size    .L.str.hwasan, 16<br>
<br>
    .type    .L.str.hwasan.descriptor,@object // @.str.hwasan.descriptor<br>
    .section    hwasan_globals,"ao",@progbits,.L.str.hwasan,unique,2<br>
    .p2align    3<br>
.L.str.hwasan.descriptor:<br>
    .word    .L.str.hwasan-.L.str.hwasan.descriptor<br>
    .word    3489660943              // 0xd000000f<br>
    .size    .L.str.hwasan.descriptor, 8<br>
<br>
    .section    .debug_str,"MS",@progbits,1<br>
.Linfo_string0:<br>
    .asciz    "clang version 10.0.1<br>
(git@github.com:llvm/llvm-project.git<br>
a634a80615b1e012f1a61aa0cd1e2e67ef77d0bd)" // string offset=0<br>
.Linfo_string1:<br>
    .asciz    "test.c"                // string offset=101<br>
.Linfo_string2:<br>
    .asciz    "/home/derrick/tmp"     // string offset=108<br>
.Linfo_string3:<br>
    .asciz    "main"                  // string offset=126<br>
.Linfo_string4:<br>
    .asciz    "int"                   // string offset=131<br>
.Linfo_string5:<br>
    .asciz    "argc"                  // string offset=135<br>
.Linfo_string6:<br>
    .asciz    "argv"                  // string offset=140<br>
.Linfo_string7:<br>
    .asciz    "char"                  // string offset=145<br>
    .section    .debug_abbrev,"",@progbits<br>
    .byte    1                       // Abbreviation Code<br>
    .byte    17                      // DW_TAG_compile_unit<br>
    .byte    1                       // DW_CHILDREN_yes<br>
    .byte    37                      // DW_AT_producer<br>
    .byte    14                      // DW_FORM_strp<br>
    .byte    19                      // DW_AT_language<br>
    .byte    5                       // DW_FORM_data2<br>
    .byte    3                       // DW_AT_name<br>
    .byte    14                      // DW_FORM_strp<br>
    .byte    16                      // DW_AT_stmt_list<br>
    .byte    23                      // DW_FORM_sec_offset<br>
    .byte    27                      // DW_AT_comp_dir<br>
    .byte    14                      // DW_FORM_strp<br>
    .byte    17                      // DW_AT_low_pc<br>
    .byte    1                       // DW_FORM_addr<br>
    .byte    18                      // DW_AT_high_pc<br>
    .byte    6                       // DW_FORM_data4<br>
    .byte    0                       // EOM(1)<br>
    .byte    0                       // EOM(2)<br>
    .byte    2                       // Abbreviation Code<br>
    .byte    46                      // DW_TAG_subprogram<br>
    .byte    1                       // DW_CHILDREN_yes<br>
    .byte    17                      // DW_AT_low_pc<br>
    .byte    1                       // DW_FORM_addr<br>
    .byte    18                      // DW_AT_high_pc<br>
    .byte    6                       // DW_FORM_data4<br>
    .byte    64                      // DW_AT_frame_base<br>
    .byte    24                      // DW_FORM_exprloc<br>
    .byte    3                       // DW_AT_name<br>
    .byte    14                      // DW_FORM_strp<br>
    .byte    58                      // DW_AT_decl_file<br>
    .byte    11                      // DW_FORM_data1<br>
    .byte    59                      // DW_AT_decl_line<br>
    .byte    11                      // DW_FORM_data1<br>
    .byte    39                      // DW_AT_prototyped<br>
    .byte    25                      // DW_FORM_flag_present<br>
    .byte    73                      // DW_AT_type<br>
    .byte    19                      // DW_FORM_ref4<br>
    .byte    63                      // DW_AT_external<br>
    .byte    25                      // DW_FORM_flag_present<br>
    .byte    0                       // EOM(1)<br>
    .byte    0                       // EOM(2)<br>
    .byte    3                       // Abbreviation Code<br>
    .byte    5                       // DW_TAG_formal_parameter<br>
    .byte    0                       // DW_CHILDREN_no<br>
    .byte    2                       // DW_AT_location<br>
    .byte    24                      // DW_FORM_exprloc<br>
    .byte    3                       // DW_AT_name<br>
    .byte    14                      // DW_FORM_strp<br>
    .byte    58                      // DW_AT_decl_file<br>
    .byte    11                      // DW_FORM_data1<br>
    .byte    59                      // DW_AT_decl_line<br>
    .byte    11                      // DW_FORM_data1<br>
    .byte    73                      // DW_AT_type<br>
    .byte    19                      // DW_FORM_ref4<br>
    .byte    0                       // EOM(1)<br>
    .byte    0                       // EOM(2)<br>
    .byte    4                       // Abbreviation Code<br>
    .byte    36                      // DW_TAG_base_type<br>
    .byte    0                       // DW_CHILDREN_no<br>
    .byte    3                       // DW_AT_name<br>
    .byte    14                      // DW_FORM_strp<br>
    .byte    62                      // DW_AT_encoding<br>
    .byte    11                      // DW_FORM_data1<br>
    .byte    11                      // DW_AT_byte_size<br>
    .byte    11                      // DW_FORM_data1<br>
    .byte    0                       // EOM(1)<br>
    .byte    0                       // EOM(2)<br>
    .byte    5                       // Abbreviation Code<br>
    .byte    15                      // DW_TAG_pointer_type<br>
    .byte    0                       // DW_CHILDREN_no<br>
    .byte    73                      // DW_AT_type<br>
    .byte    19                      // DW_FORM_ref4<br>
    .byte    0                       // EOM(1)<br>
    .byte    0                       // EOM(2)<br>
    .byte    0                       // EOM(3)<br>
    .section    .debug_info,"",@progbits<br>
.Lcu_begin0:<br>
    .word    .Ldebug_info_end0-.Ldebug_info_start0 // Length of Unit<br>
.Ldebug_info_start0:<br>
    .hword    4                       // DWARF version number<br>
    .word    .debug_abbrev           // Offset Into Abbrev. Section<br>
    .byte    8                       // Address Size (in bytes)<br>
    .byte    1                       // Abbrev [1] 0xb:0x6e DW_TAG_compile_unit<br>
    .word    .Linfo_string0          // DW_AT_producer<br>
    .hword    12                      // DW_AT_language<br>
    .word    .Linfo_string1          // DW_AT_name<br>
    .word    .Lline_table_start0     // DW_AT_stmt_list<br>
    .word    .Linfo_string2          // DW_AT_comp_dir<br>
    .xword    .Lfunc_begin0           // DW_AT_low_pc<br>
    .word    .Lfunc_end0-.Lfunc_begin0 // DW_AT_high_pc<br>
    .byte    2                       // Abbrev [2] 0x2a:0x36 DW_TAG_subprogram<br>
    .xword    .Lfunc_begin0           // DW_AT_low_pc<br>
    .word    .Lfunc_end0-.Lfunc_begin0 // DW_AT_high_pc<br>
    .byte    1                       // DW_AT_frame_base<br>
    .byte    109<br>
    .word    .Linfo_string3          // DW_AT_name<br>
    .byte    1                       // DW_AT_decl_file<br>
    .byte    3                       // DW_AT_decl_line<br>
                                        // DW_AT_prototyped<br>
    .word    96                      // DW_AT_type<br>
                                        // DW_AT_external<br>
    .byte    3                       // Abbrev [3] 0x43:0xe<br>
DW_TAG_formal_parameter<br>
    .byte    2                       // DW_AT_location<br>
    .byte    145<br>
    .byte    120<br>
    .word    .Linfo_string5          // DW_AT_name<br>
    .byte    1                       // DW_AT_decl_file<br>
    .byte    3                       // DW_AT_decl_line<br>
    .word    96                      // DW_AT_type<br>
    .byte    3                       // Abbrev [3] 0x51:0xe<br>
DW_TAG_formal_parameter<br>
    .byte    2                       // DW_AT_location<br>
    .byte    145<br>
    .byte    112<br>
    .word    .Linfo_string6          // DW_AT_name<br>
    .byte    1                       // DW_AT_decl_file<br>
    .byte    3                       // DW_AT_decl_line<br>
    .word    103                     // DW_AT_type<br>
    .byte    0                       // End Of Children Mark<br>
    .byte    4                       // Abbrev [4] 0x60:0x7 DW_TAG_base_type<br>
    .word    .Linfo_string4          // DW_AT_name<br>
    .byte    5                       // DW_AT_encoding<br>
    .byte    4                       // DW_AT_byte_size<br>
    .byte    5                       // Abbrev [5] 0x67:0x5 DW_TAG_pointer_type<br>
    .word    108                     // DW_AT_type<br>
    .byte    5                       // Abbrev [5] 0x6c:0x5 DW_TAG_pointer_type<br>
    .word    113                     // DW_AT_type<br>
    .byte    4                       // Abbrev [4] 0x71:0x7 DW_TAG_base_type<br>
    .word    .Linfo_string7          // DW_AT_name<br>
    .byte    8                       // DW_AT_encoding<br>
    .byte    1                       // DW_AT_byte_size<br>
    .byte    0                       // End Of Children Mark<br>
.Ldebug_info_end0:<br>
.set .L.str, .L.str.hwasan-3458764513820540928<br>
    .size    .L.str, 15<br>
    .ident    "clang version 10.0.1<br>
(git@github.com:llvm/llvm-project.git<br>
a634a80615b1e012f1a61aa0cd1e2e67ef77d0bd)"<br>
    .section    ".note.GNU-stack","",@progbits<br>
    .addrsig<br>
    .addrsig_sym printf<br>
    .addrsig_sym __hwasan_init<br>
    .addrsig_sym hwasan.module_ctor<br>
    .addrsig_sym __start_hwasan_globals<br>
    .addrsig_sym __stop_hwasan_globals<br>
    .addrsig_sym .Lhwasan.note<br>
    .addrsig_sym .Lhwasan.dummy.global<br>
    .addrsig_sym .L.str.hwasan<br>
    .addrsig_sym .L.str.hwasan.descriptor<br>
    .addrsig_sym .L.str<br>
    .section    .text.hot,"axG",@progbits,__hwasan_check_x2_18_short,comdat<br>
    .type    __hwasan_check_x2_18_short,@function<br>
    .weak    __hwasan_check_x2_18_short<br>
    .hidden    __hwasan_check_x2_18_short<br>
__hwasan_check_x2_18_short:<br>
    ubfx    x16, x2, #4, #52<br>
    ldrb    w16, [x9, x16]<br>
    cmp    x16, x2, lsr #56<br>
    <a href="http://b.ne" rel="noreferrer" target="_blank">b.ne</a>    .Ltmp2<br>
.Ltmp3:<br>
    ret<br>
.Ltmp2:<br>
    cmp    w16, #15                // =15<br>
    b.hi    .Ltmp4<br>
    and    x17, x2, #0xf<br>
    add    x17, x17, #3            // =3<br>
    cmp    w16, w17<br>
    <a href="http://b.ls" rel="noreferrer" target="_blank">b.ls</a>    .Ltmp4<br>
    orr    x16, x2, #0xf<br>
    ldrb    w16, [x16]<br>
    cmp    x16, x2, lsr #56<br>
    b.eq    .Ltmp3<br>
.Ltmp4:<br>
    stp    x0, x1, [sp, #-256]!<br>
    stp    x29, x30, [sp, #232]<br>
    mov    x0, x2<br>
    mov    x1, #18<br>
    adrp    x16, :got:__hwasan_tag_mismatch_v2<br>
    ldr    x16, [x16, :got_lo12:__hwasan_tag_mismatch_v2]<br>
    br    x16<br>
    .section    .text.hot,"axG",@progbits,__hwasan_check_x2_19_short,comdat<br>
    .type    __hwasan_check_x2_19_short,@function<br>
    .weak    __hwasan_check_x2_19_short<br>
    .hidden    __hwasan_check_x2_19_short<br>
__hwasan_check_x2_19_short:<br>
    ubfx    x16, x2, #4, #52<br>
    ldrb    w16, [x9, x16]<br>
    cmp    x16, x2, lsr #56<br>
    <a href="http://b.ne" rel="noreferrer" target="_blank">b.ne</a>    .Ltmp5<br>
.Ltmp6:<br>
    ret<br>
.Ltmp5:<br>
    cmp    w16, #15                // =15<br>
    b.hi    .Ltmp7<br>
    and    x17, x2, #0xf<br>
    add    x17, x17, #7            // =7<br>
    cmp    w16, w17<br>
    <a href="http://b.ls" rel="noreferrer" target="_blank">b.ls</a>    .Ltmp7<br>
    orr    x16, x2, #0xf<br>
    ldrb    w16, [x16]<br>
    cmp    x16, x2, lsr #56<br>
    b.eq    .Ltmp6<br>
.Ltmp7:<br>
    stp    x0, x1, [sp, #-256]!<br>
    stp    x29, x30, [sp, #232]<br>
    mov    x0, x2<br>
    mov    x1, #19<br>
    adrp    x16, :got:__hwasan_tag_mismatch_v2<br>
    ldr    x16, [x16, :got_lo12:__hwasan_tag_mismatch_v2]<br>
    br    x16<br>
    .section    .debug_line,"",@progbits<br>
.Lline_table_start0:<br>
<br>
On Mon, Jun 22, 2020 at 4:37 PM Mitch Phillips <<a href="mailto:mitchp@google.com" target="_blank">mitchp@google.com</a>> wrote:<br>
><br>
> Hi Derrick,<br>
><br>
> Can you send through `test.c`? What does clang's assembly say (`path/to/compiled/clang --target=aarch64-linux-gnu -march=armv8.5-a -fsanitize=hwaddress -S test.c; cat test.s`)?<br>
><br>
> - Mitch<br>
><br>
> On Mon, Jun 22, 2020 at 12:04 PM Derrick McKee via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> I am trying to execute a simple hello world program compiled like so:<br>
>><br>
>> path/to/compiled/clang -o test --target=aarch64-linux-gnu<br>
>> -march=armv8.5-a -fsanitize=hwaddress<br>
>> --sysroot=/usr/aarch64-linux-gnu/<br>
>> -L/usr/lib/gcc/aarch64-linux-gnu/10.1.0/ -g test.c<br>
>><br>
>> However, when I look at the disassembly, there is an unknown<br>
>> instruction listed at 0x2d51c:<br>
>><br>
>> 000000000002d4c0 main:<br>
>>    2d4c0: ff c3 00 d1                      sub    sp, sp, #48<br>
>>    2d4c4: fd 7b 02 a9                      stp    x29, x30, [sp, #32]<br>
>>    2d4c8: fd 83 00 91                      add    x29, sp, #32<br>
>>    2d4cc: 08 01 00 d0                      adrp    x8, #139264<br>
>>    2d4d0: 08 49 47 f9                      ldr    x8, [x8, #3728]<br>
>>    2d4d4: 49 d0 3b d5                      mrs    x9, TPIDR_EL0<br>
>>    2d4d8: 28 69 68 f8                      ldr    x8, [x9, x8]<br>
>>    2d4dc: 08 7d 40 b2                      orr    x8, x8, #0xffffffff<br>
>>    2d4e0: 08 05 00 91                      add    x8, x8, #1<br>
>>    2d4e4: a2 13 00 d1                      sub    x2, x29, #4<br>
>>    2d4e8: e9 03 08 aa                      mov    x9, x8<br>
>>    2d4ec: df 64 ff 97                      bl    #-158852<br>
>> <__hwasan_check_x2_18_short><br>
>>    2d4f0: ea 03 1f 2a                      mov    w10, wzr<br>
>>    2d4f4: aa c3 1f b8                      stur    w10, [x29, #-4]<br>
>>    2d4f8: a2 23 00 d1                      sub    x2, x29, #8<br>
>>    2d4fc: e9 03 08 aa                      mov    x9, x8<br>
>>    2d500: da 64 ff 97                      bl    #-158872<br>
>> <__hwasan_check_x2_18_short><br>
>>    2d504: a0 83 1f b8                      stur    w0, [x29, #-8]<br>
>>    2d508: e2 43 00 91                      add    x2, sp, #16<br>
>>    2d50c: e9 03 08 aa                      mov    x9, x8<br>
>>    2d510: ec 64 ff 97                      bl    #-158800<br>
>> <__hwasan_check_x2_19_short><br>
>>    2d514: e1 0b 00 f9                      str    x1, [sp, #16]<br>
>>    2d518: 40 00 00 d0                      adrp    x0, #40960<br>
>>    2d51c: e0 ff e5 b2                      <unknown><br>
>>    2d520: 00 40 35 91                      add    x0, x0, #3408<br>
>>    2d524: ea 0f 00 b9                      str    w10, [sp, #12]<br>
>>    2d528: c2 64 ff 97                      bl    #-158968 <printf@plt><br>
>>    2d52c: ea 0f 40 b9                      ldr    w10, [sp, #12]<br>
>>    2d530: e0 0b 00 b9                      str    w0, [sp, #8]<br>
>>    2d534: e0 03 0a 2a                      mov    w0, w10<br>
>>    2d538: fd 7b 42 a9                      ldp    x29, x30, [sp, #32]<br>
>>    2d53c: ff c3 00 91                      add    sp, sp, #48<br>
>>    2d540: c0 03 5f d6                      ret<br>
>><br>
>><br>
>> Am I compiling the program incorrectly?  For reference, here's my clang version<br>
>><br>
>> # llvm-project/build-10.x/install/bin/clang --version<br>
>>                                              [1]<br>
>> clang version 10.0.1 (git@github.com:llvm/llvm-project.git<br>
>> a634a80615b1e012f1a61aa0cd1e2e67ef77d0bd)<br>
>> Target: x86_64-unknown-linux-gnu<br>
>> Thread model: posix<br>
>><br>
>> --<br>
>> Derrick McKee<br>
>> Phone: <a href="tel:(703)%20957-9362" value="+17039579362" target="_blank">(703) 957-9362</a><br>
>> Email: <a href="mailto:derrick.mckee@gmail.com" target="_blank">derrick.mckee@gmail.com</a><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
<br>
<br>
-- <br>
Derrick McKee<br>
Phone: <a href="tel:(703)%20957-9362" value="+17039579362" target="_blank">(703) 957-9362</a><br>
Email: <a href="mailto:derrick.mckee@gmail.com" target="_blank">derrick.mckee@gmail.com</a><br>
</blockquote></div>