Giter VIP home page Giter VIP logo

Comments (3)

jrosengarden avatar jrosengarden commented on August 25, 2024 3

Thank-you VERY, VERY, VERY much. That worked perfectly and I've modified my program to now grab the command line argument(s) entered and act on them accordingly.

Again....thanks tons. Much appreciated!!!!!!

from hellosilicon.

below avatar below commented on August 25, 2024 1

Gladly, it is quite easy. This is the entry function:

int main (int argc, const char * argv[])

As per the standard ARM64 ABI, the arguments are in the registers:
x0 holds argc
x1 holds argv

Let's invoke our executable with lldb HelloSilicon foo, and look at the register when our _start routine is called:

(lldb) re r sp x0 x1
      sp = 0x000000016fdff970
      x0 = 0x0000000000000002
      x1 = 0x000000016fdff9a0

As you can see, x0 contains 2, and x1 points to a position 48 bytes above the current SP (and we can find the value for argc at 40 bytes, too).

When we examine the memory pointed to at x1, we see the elements of argv, which are in turn pointers:

(lldb) m read -fx -c32 0x000000016fdff9a0
0x16fdff9a0: 0x6fdffb20 0x00000001 0x6fdffb53 0x00000001

The memory pointed to by the doubleword at x1 contains, as expected, the full path to the executable:

(lldb) m read -fc -c51 0x000000016fdffb20
0x16fdffb20: /Users/below/dev/HelloSilicon/Ch
0x16fdffb40: apter 1/HelloWorld\0

And finally, the doubleword at [x1, #8] points to our argument, foo:

(lldb) m read -fc -c4 0x000000016fdffb53
0x16fdffb53: foo\0

With this information, it should be easy to adopt your code! Let me know if it works!

from hellosilicon.

below avatar below commented on August 25, 2024

Please see my adaption of your code in Chapter 4/case.s and feel free to add or edit it

from hellosilicon.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.