• ARM Dis-assembler for GForth

    From Brian Fox@21:1/5 to All on Thu Feb 2 18:29:48 2023
    A question came up on Reddit /Forth by a person with an Apple M1.
    They tried to use SEE but code words would not dis-assemble.
    Is there anyone thinking about making one in Forth?
    Could gFoRTH be made to interface to gbd in a workable way?

    Asking for a friend.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Brian Fox on Fri Feb 3 07:00:17 2023
    Brian Fox <brian.fox@brianfox.ca> writes:
    A question came up on Reddit /Forth by a person with an Apple M1.
    They tried to use SEE but code words would not dis-assemble.
    Is there anyone thinking about making one in Forth?
    Could gFoRTH be made to interface to gbd in a workable way?

    Gforth has had a gdb-based disassembler since 0.7. Some OSs
    (e.g. Ubuntu) by default maim the ptrace system call and disasm-gdb
    does not work there. On Ubuntu you can fix this with

    sudo echo 0 >/proc/sys/kernel/yama/ptrace_scope

    or (after the next reboot) by changing /etc/sysctl.d/10-ptrace.conf

    The development version of Gforth also has Forth disassemblers for the
    ARM A64 (aka Aarch64) and some 32-bit ARM instruction set:

    Here's on a A64 Ubuntu system with the fix above, using gforth-fast in
    either case:

    Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
    Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
    Type `bye' to exit
    see +
    Code +
    0x0000aaaae8bfa884 <gforth_engine+3220>: ldr x0, [x23, #8]!
    0x0000aaaae8bfa888 <gforth_engine+3224>: add x25, x25, #0x8
    0x0000aaaae8bfa88c <gforth_engine+3228>: add x24, x24, x0
    0x0000aaaae8bfa890 <gforth_engine+3232>: ldur x2, [x25, #-8]
    0x0000aaaae8bfa894 <gforth_engine+3236>: br x2
    0x0000aaaae8bfa898 <gforth_engine+3240>: ldur x2, [x25, #-8]
    0x0000aaaae8bfa89c <gforth_engine+3244>: br x2
    0x0000aaaae8bfa8a0 <gforth_engine+3248>: br x2
    0x0000aaaae8bfa8a4 <gforth_engine+3252>: mov x4, x25
    0x0000aaaae8bfa8a8 <gforth_engine+3256>: ldr x0, [x4], #8
    0x0000aaaae8bfa8ac <gforth_engine+3260>: add x24, x0, x24
    0x0000aaaae8bfa8b0 <gforth_engine+3264>: add x25, x4, #0x8
    0x0000aaaae8bfa8b4 <gforth_engine+3268>: ldur x2, [x25, #-8]
    0x0000aaaae8bfa8b8 <gforth_engine+3272>: br x2
    Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
    Use 'set logging enabled off'.

    end-code

    Gforth 0.7.9_20230114
    ...
    see +
    Code +
    AAAAADB6DF70: ldr x0, [x25,#0x8]!
    AAAAADB6DF74: add x26, x26, #0x8
    AAAAADB6DF78: add x27, x0, x27
    AAAAADB6DF7C: ldur x1, [x26,#-0x8]
    AAAAADB6DF80: br x1
    end-code
    ok
    ' disasm-gdb is discode ok
    see +
    Code +
    0x0000aaaaadb6df70 <gforth_engine+2640>: ldr x0, [x25, #8]!
    0x0000aaaaadb6df74 <gforth_engine+2644>: add x26, x26, #0x8
    0x0000aaaaadb6df78 <gforth_engine+2648>: add x27, x0, x27
    0x0000aaaaadb6df7c <gforth_engine+2652>: ldur x1, [x26, #-8]
    0x0000aaaaadb6df80 <gforth_engine+2656>: br x1
    Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
    Use 'set logging enabled off'.

    end-code

    Development Gforth did not work on MacOS on Apple Silicon last time I
    tried it.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2022: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to Anton Ertl on Fri Feb 3 12:28:03 2023
    In article <2023Feb3.080017@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    <SNIP>
    Development Gforth did not work on MacOS on Apple Silicon last time I
    tried it.

    I heard that the newest apple have a change of type of processor.
    Does gforth run on those already?


    - anton

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@cherry. on Fri Feb 3 12:33:58 2023
    albert@cherry.(none) (albert) writes:
    In article <2023Feb3.080017@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    <SNIP>
    Development Gforth did not work on MacOS on Apple Silicon last time I
    tried it.

    I heard that the newest apple have a change of type of processor.

    It is unclear what you mean.

    Does gforth run on those already?

    Gforth runs on the Apple M1 on Linux without problems. I expect that
    it runs on the Apple M2 on Linux, too.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2022: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brian Fox@21:1/5 to Anton Ertl on Fri Feb 3 12:53:07 2023
    On Friday, February 3, 2023 at 2:17:50 AM UTC-5, Anton Ertl wrote:
    Brian Fox <bria...@brianfox.ca> writes:
    A question came up on Reddit /Forth by a person with an Apple M1.
    They tried to use SEE but code words would not dis-assemble.
    Is there anyone thinking about making one in Forth?
    Could gFoRTH be made to interface to gbd in a workable way?
    Gforth has had a gdb-based disassembler since 0.7. Some OSs
    (e.g. Ubuntu) by default maim the ptrace system call and disasm-gdb
    does not work there. On Ubuntu you can fix this with

    sudo echo 0 >/proc/sys/kernel/yama/ptrace_scope

    or (after the next reboot) by changing /etc/sysctl.d/10-ptrace.conf

    The development version of Gforth also has Forth disassemblers for the
    ARM A64 (aka Aarch64) and some 32-bit ARM instruction set:

    Here's on a A64 Ubuntu system with the fix above, using gforth-fast in
    either case:

    Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
    Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
    Type `bye' to exit
    see +
    Code +
    0x0000aaaae8bfa884 <gforth_engine+3220>: ldr x0, [x23, #8]! 0x0000aaaae8bfa888 <gforth_engine+3224>: add x25, x25, #0x8 0x0000aaaae8bfa88c <gforth_engine+3228>: add x24, x24, x0
    0x0000aaaae8bfa890 <gforth_engine+3232>: ldur x2, [x25, #-8] 0x0000aaaae8bfa894 <gforth_engine+3236>: br x2
    0x0000aaaae8bfa898 <gforth_engine+3240>: ldur x2, [x25, #-8] 0x0000aaaae8bfa89c <gforth_engine+3244>: br x2
    0x0000aaaae8bfa8a0 <gforth_engine+3248>: br x2
    0x0000aaaae8bfa8a4 <gforth_engine+3252>: mov x4, x25
    0x0000aaaae8bfa8a8 <gforth_engine+3256>: ldr x0, [x4], #8
    0x0000aaaae8bfa8ac <gforth_engine+3260>: add x24, x0, x24
    0x0000aaaae8bfa8b0 <gforth_engine+3264>: add x25, x4, #0x8
    0x0000aaaae8bfa8b4 <gforth_engine+3268>: ldur x2, [x25, #-8] 0x0000aaaae8bfa8b8 <gforth_engine+3272>: br x2
    Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
    Use 'set logging enabled off'.

    end-code

    Gforth 0.7.9_20230114
    ...
    see +
    Code +
    AAAAADB6DF70: ldr x0, [x25,#0x8]!
    AAAAADB6DF74: add x26, x26, #0x8
    AAAAADB6DF78: add x27, x0, x27
    AAAAADB6DF7C: ldur x1, [x26,#-0x8]
    AAAAADB6DF80: br x1
    end-code
    ok
    ' disasm-gdb is discode ok
    see +
    Code +
    0x0000aaaaadb6df70 <gforth_engine+2640>: ldr x0, [x25, #8]! 0x0000aaaaadb6df74 <gforth_engine+2644>: add x26, x26, #0x8 0x0000aaaaadb6df78 <gforth_engine+2648>: add x27, x0, x27
    0x0000aaaaadb6df7c <gforth_engine+2652>: ldur x1, [x26, #-8] 0x0000aaaaadb6df80 <gforth_engine+2656>: br x1
    Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
    Use 'set logging enabled off'.

    end-code

    Development Gforth did not work on MacOS on Apple Silicon last time I
    tried it.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2022: https://euro.theforth.net

    Thanks Anton

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)