حبيب محمد الأمين محمد الهـاد <ha.ala...@gmail.com> writes:

> New progress update.
>
> I got stage 1 and 2 to build together(!) in just 2 hours. As before,
> stage 2 compiler seems to be copied.

That's exciting. Now that you have the recipe reproduced more than once,
maybe you can document it well enough for others to try following at
home?

> I was unable to use the stage 1 compiler to link aarch64 binaries, I
> got:
>
> ld: error: relocation R_AARCH64_ABS64 cannot be used against local symbol; 
> recompile with -fPIC
>
> When I reran with -v3, I manually ran each command it showed, and it
> failed at the link stage with:
>
> ld.lld: error: can't create dynamic relocation R_AARCH64_ABS64 against local 
> symbol in readonly segment; recompile object files
> with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the
> output

-z,notext used to be necessary for i386. While it's weird that arm64
requires this, we can probalby resolve this once we have anything
working on arm64.

>
> I could see the commands contained -fno-PIC, but rerunning the commands
> with -fPIC didn't work, so I added -Wl,-z,notext to them, and that
> got rid of the errors, but when I tried to run the command on my
> OpenBSD/arm64 VM, I got (whether run from $HOME or /usr/local/bin):
>
> Trace/BPT trap (core dumped)
>
> Running via lld, I get:
>
> openbsd-arm64-host$ lldb /usr/local/bin/hello                                 
>          
> (lldb) target create "/usr/local/bin/hello"
> Current executable set to '/usr/local/bin/hello' (aarch64).
> (lldb) run
> Process 65280 launched: '/usr/local/bin/hello' (aarch64)
> Process 65280 stopped
> * thread #1, stop reason = signal SIGTRAP
>     frame #0: 0x00000007234d8040 hello`StgRun + 204
> hello`StgRun:
> ->  0x7234d8040 <+204>: brk    #0x1
>     0x7234d8044 <+208>: ret    

I don't know what the epilogues on arm64 are like. This looks vaguely
similar to retguard stack smashing detection. If you disassemble the
whole hello`StgRun, somebody more knowledgeable might be able to tell us
what's going on.

Thanks
Greg

Reply via email to