Skip to content
  • Sylvain Henry's avatar
    NCG: correctly handle addresses with huge offsets (#15570) · 3cdd8d69
    Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
    Before this patch we could generate addresses of this form:
    
       movzbl cP0_str+-9223372036854775808,%eax
    
    The linker can't handle them because the offset is too large:
    
       ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647]
    
    With this patch we detect those cases and generate:
    
       movq $-9223372036854775808,%rax
       addq $cP0_str,%rax
       movzbl (%rax),%eax
    
    I've also refactored `getAmode` a little bit to make it easier to
    understand and to trace.
    3cdd8d69