https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577

--- Comment #39 from The Written Word <bugzilla-gcc at thewrittenword dot com> 
---
(In reply to EML from comment #25)
> I have applied the patch and tried your other suggestions, still the stage1
> compiler has the same problems generating executables.
> 
> In analyzing the intermediate files between working (gcc 4.93) and not
> (bootstrap 8.3), the intermediate files seem similar until the "mach" stage
> 
> The problem seems to be in out the compiler decides to reference a string in
> the source.
> 
> My program is:
> 
> #include <stdio.h>
> 
> int main()
> {
>         printf("Hellos World\n");
>         return 0;
> }
> 
> The generated .s file for Working does this:
> 
> .LC0:
>         stringz "Hellos World"
> 
> <edited for breivity>
> 
>         addl r36 = @ltoffx(.LC0), r1
>         ;;
>         ld8.mov r36 = [r36], .LC0
> 
> The non-working .s file does this:
> 
> .LC0:
>         stringz "Hellos World"
> 
> <edited for breivity>
> 
>         movl r36 = @gprel(.LC0)
>         ;;
>         add r36 = r1, r36
> 
> 
> If I replace those 3 lines and run the assembler+linker by hand - the
> non-working foo.s will run correctly

I can now duplicate what you're seeing:
$ diff -u gcc-4.9.4/hello.s gcc-8.3.0/hello.s
--- gcc-4.9.3/hello.s        2019-07-05 04:55:49 +0000
+++ gcc-8.3.0/hello.s     2019-07-05 04:55:44 +0000
@@ -1,5 +1,6 @@
        .file   "hello.c"
        .pred.safe_across_calls p1-p5,p16-p63
+       .section        .text,  "ax",   "progbits"
        .section        .rodata,        "a",    "progbits"
        .align 8
 .LC0:
@@ -19,9 +20,9 @@
        mov r32 = b0
        mov r35 = r1
        .body
-       addl r36 = @ltoffx(.LC0), r1
+       movl r36 = @gprel(.LC0)
        ;;
-       ld8.mov r36 = [r36], .LC0
+       add r36 = r1, r36
        br.call.sptk.many b0 = puts#
        mov r1 = r35
        mov r14 = r0

$ grep LTOFF <objdir>/gcc/config.status
D["HAVE_AS_LTOFFX_LDXMOV_RELOCS"]=" 1"

Reply via email to