Foundations of ARM64 Linux Debugging, Disassembling, and Reversing: Analyze Code, Understand Stack Memory Usage, and Reconstruct Original - podcast episode cover

Foundations of ARM64 Linux Debugging, Disassembling, and Reversing: Analyze Code, Understand Stack Memory Usage, and Reconstruct Original

Apr 01, 202512 min
--:--
--:--
Download Metacast podcast app
Listen to this episode in Metacast mobile app
Don't just listen to podcasts. Learn from them with transcripts, summaries, and chapters for every episode. Skim, search, and bookmark insights. Learn more

Episode description

Dmitry Vostokov's Book, Foundations of ARM64 Linux Debugging, Disassembling, and Reversing, provides a practical guide to understanding ARM64 assembly language and its relationship to C/C++ code. The book uses numerous examples and diagrams to illustrate concepts like memory management, registers, pointers, and stack operations within the ARM64 architecture. It emphasizes hands-on exercises using the GDB debugger to analyze code, understand memory usage, and reconstruct original source code. The text covers code optimization techniques and different number representation systems, building a strong foundation for debugging and reverse engineering Linux applications. The book targets software engineers, security researchers, and students seeking to enhance their understanding of low-level programming and debugging.



You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary

Get the Book now from Amazon:
https://www.amazon.com/Foundations-ARM64-Debugging-Disassembling-Reversing/dp/148429081X?&linkCode=ll1&tag=cvthunderx-20&linkId=634ef31738ce13949eb56422d8c87fc8&language=en_US&ref_=as_li_ss_tl


Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy

Transcript

Speaker 1

Welcome to the deep Dive. Today. We're going to be taking a look at ARM sixty four architecture, you know, the stuff that powers a lot of our devices.

Speaker 2

It's kind of like getting it behind the scenes tour to see how the magic happens in our tech exactly.

Speaker 1

We're going to be talking about how software actually works, like going under the hood and figuring out what makes it tick.

Speaker 2

We'll be diving into memory registers, even those kind of mysterious sounding pointers. Sounds complicated, it can be, but don't worry, we'll break it all down.

Speaker 1

This deep dive is for everyone, even if you're not a programmer. It's all about understanding those fundamental building blocks because when.

Speaker 2

You understand the basics, you get a whole new appreciation for how the technology you use every day actually functions.

Speaker 1

So let's start with memory. It's basically the heart of any computer, right absolutely.

Speaker 2

One of the sources we looked at described it as a city, with each piece of data living in a house with a specific address.

Speaker 1

Okay, I can kind of see that like a giant city of data.

Speaker 2

Right, but imagine it more like a massive, well organized warehouse instead. Each piece of data has its own numbered storage unit and that number is its address.

Speaker 1

Okay, I like that a warehouse full of information, And then those addressing modes are kind of like the different ways to navigate that warehouse, right, you got it.

Speaker 2

Some modes like direct addressing are like having the exact storage unit number. Others like using offsets, are more like saying, go to aisle five, then move three units to the right.

Speaker 1

So it's all about finding the data you need quickly and efficiently.

Speaker 2

Exactly, And this is especially important when you're dealing with a lot of data or you need to access it in a specific order.

Speaker 1

It's all about optimization.

Speaker 2

You got it.

Speaker 1

Okay, that makes sense. But before we get lost in the warehouse, let's talk about those registers mentioned in the sources. Are those like a special VIP section for super important data? Uh?

Speaker 2

I like that. Analogy registers are like high speed shelves right next to the processor, the brains of the computer. They hold the data that the processor needs to access really quickly.

Speaker 1

So if our warehouse is the main memory, registers are like having a few key items right on your workbench for instant access, exactly.

Speaker 2

And with AIRM sixty four, these shelves are sixty four bits.

Speaker 1

Wide, meaning they can hold a lot more information, much.

Speaker 2

More compared to older thirty two bit systems. It's like upgrading from a handtruck to a forklift when it comes to moving data around.

Speaker 1

Okay, so that's why sixty four bit systems can feel so much faster. They're handling more information at once.

Speaker 2

That's one of the key factors. And it's not just about speed. It's also about capacity.

Speaker 1

Capacity You mean how much data it can store.

Speaker 2

Well, not exactly. It's more about how many different memory locations a sixty four bit system can access.

Speaker 1

So it's like having a map of the entire city instead of just one neighborhood.

Speaker 2

You got it, And that means sixty four bit systems are much better equipped to handle those huge, complex programs we're using today.

Speaker 1

Makes sense, but we're gonna have to save that conversation for another time.

Speaker 2

Okay, sound good.

Speaker 1

Right now, let's get back to those mysterious pointers we mentioned earlier. Those things kind of sad, like something out of a spy movie.

Speaker 2

They do, don't they?

Speaker 1

What are they really think of?

Speaker 2

Pointers like labels, each one containing the address of a specific piece of data in memory. They don't hold the data itself. They just tell you where to find it.

Speaker 1

So it's like having a treasure map that leads you to the buried treasure exactly.

Speaker 2

And pointers can be stored in regular memory or in those high speed registers we talked about.

Speaker 1

Hold on, So are you saying that pointers themselves have addresses too? That's kind of trippy.

Speaker 2

It is. A pointer is just another piece of data, so it has its own address in memory. Think of it like a library card catalog. The card has a specific spot in the catalog, but it also points you to the location of the book you're looking for.

Speaker 1

Okay, So pointers are like master organizers, creating this intricate web of interconnected data within the memory warehouse. But you mentioned earlier they can be dangerous. What did you mean by that?

Speaker 2

That's where things get really interesting, and that's exactly what we'll explore next time.

Speaker 1

All right, So we've got our memory warehouse, those speedy registers and those kind of mysterious pointers. But you said pointers can be a bit risky. Why is that.

Speaker 2

Well, it's like having a map, but you got to make sure it's the right map and you're allowed to go where.

Speaker 1

It's pointing right, Otherwise you might end up in some restricted zone exactly.

Speaker 2

And one of the biggest dangers is what we call it annul pointer. It's basically like having a map that leads to nowhere.

Speaker 1

Okay, so what happens if a program tries to use an annul pointer? Does it just get lost?

Speaker 2

It's more like hitting a wall, imagine trying to access a storage unit that doesn't even exist.

Speaker 1

So the program just crashes.

Speaker 2

Pretty much on Linux, that's usually what happens.

Speaker 1

Well, that seems like a good safety feature, like better to crash than to keep going and potentially mess things up even worse, right.

Speaker 2

You got it. The operating system is basically like Nope, not gonna let you do that, shutting you down to prevent any more damage.

Speaker 1

So it's like a security guard for our warehouse, making sure no one's snooping around where they shouldn't be.

Speaker 2

Precisely, it's all about keeping things stable and preventing data corruption.

Speaker 1

Okay, makes sense. Nul pointers are bad news. But are there other ways these pointers can go wrong? Oh?

Speaker 2

Yeah, definitely. There's a whole category called invalid pointers.

Speaker 1

So annul pointers are just one type of invalid pointer exactly.

Speaker 2

It's just one way a pointer can be invalid. Another way is if it's trying to access a part of memory that's off limits.

Speaker 1

Okay, back to our warehouse. That would be like trying to break into the vault without the right security clearance.

Speaker 2

Exactly, And just like a vault has alarms and security measures, so does the operating system. This is called an access violation.

Speaker 1

So what happens then? Does the alarm go off?

Speaker 2

Yeah? In a way, the program usually crashes, just like with an ANUL pointer.

Speaker 1

Okay, So the operating system is shutting things down to protect the integrity of the data.

Speaker 2

Exactly. It's all about maintaining order and preventing chaos in our memory warehouse.

Speaker 1

So we've got NLL pointers pointing to nothing, invalid pointers trying to break into restricted areas. Are there any other ways pointers can go rogue?

Speaker 2

There are. There's also the possibility of a pointer trying to change data that's supposed to be read only.

Speaker 1

So in our warehouse analogy, that would be like trying to scribble all over an important historical.

Speaker 2

Document, precisely, and that could lead to all sorts of problems, potentially even data corruption.

Speaker 1

Okay. So it's like you can look, but don't touch exactly.

Speaker 2

And on that note, let's talk about random pointers, which are kind of a wild card.

Speaker 1

Random pointers, what are those?

Speaker 2

They happen when a pointer hasn't been assigned to specific address. It's like grabbing a random map and just hoping for the best.

Speaker 1

You mean, it could point anywhere pretty much.

Speaker 2

Sometimes it might work out okay, but other times it can lead to crashes or other unpredictable behavior.

Speaker 1

Okay, so we got to make sure our pointers are initialized properly and pointing to the right places.

Speaker 2

Absolutely. And speaking of pointing to the right places, there's another tricky one called a dangling pointer.

Speaker 1

Dangling pointers, what makes those different?

Speaker 2

Think of it this way. You have a pointer pointing to some data. Everything's working fine, but then that data gets to or moved to a different location.

Speaker 1

Oh, so the pointer is still pointing to the old spot, but there's nothing there anymore.

Speaker 2

Exactly. It's like having a map to a building that's been demolished.

Speaker 1

And if you try to use that pointer, what happens, Well.

Speaker 2

It might seem like it's working for a while, but eventually it's going to cause problems, crashes, strange behavior, all sorts of things.

Speaker 1

Dangling pointers, random pointers, and ulel pointers in valid pointers. It sounds like there are a lot of ways for things to go wrong.

Speaker 2

There are, and that's why understanding how pointers work and how to use them safely is absolutely crucial when you're dealing with memory management.

Speaker 1

It sounds like there's a lot of power but also a lot of responsibility.

Speaker 2

Exactly, And that's actually a good segue into something else. We wanted to talk about how variables themselves can actually be used as pointers in C and C plus plus.

Speaker 1

Feel wait, hold on, variables can be pointers. I thought those were two completely different things.

Speaker 2

They are, but in those languages, a variable can actually play both roles.

Speaker 1

So it's like having a box that can hold both the treasure and the map to the treasure.

Speaker 2

That's a great way to put it, and that's part of what makes C and C plus plus so powerful and flexible. But it also means things can get a bit more complex.

Speaker 1

Okay, my brain is definitely starting to feel a little full. Here. Can you give me an example of how this works.

Speaker 2

Sure, let's take a look at a project called memory pointers that demonstrates this concept.

Speaker 1

Okay, so we're back in the warehouse and this memory pointers project shows us how variables can be used as pointers, right.

Speaker 2

Exactly, there's a part in the code where we have two regular integer variables A and B that we have two more variables, paw and p but these are pointer variables. So at the beginning, the pointer PB is set up to point to the memory location of the.

Speaker 1

Variable B, so PB is like a map that leads you straight to where B is stored.

Speaker 2

You got it. And then the code takes the pointer paw and assigns that the address of the variable A.

Speaker 1

So now both of our pointer variables paw and key are holding the addresses of A and B, right, And this.

Speaker 2

Is where things get really interesting, because now the code uses these pointers to actually change the value stored in A and B.

Speaker 1

So instead of working directly with the data itself, we're using pointers to indirectly access and modify it, kind of like a remote control exactly.

Speaker 2

For example, the code uses the notation paw to get to the value stored at the memory location pointed to by.

Speaker 1

PAW, so pause like a shortcut to get to the value of A without actually using A directly.

Speaker 2

You got it. And then the code can do things like add the values of A and B together, but it does it using the pointers.

Speaker 1

So it's still doing regular math like addition, but it's accessing the numbers through those pointers precisely.

Speaker 2

Pointers give programmers a powerful way to manage memory and manipulate data, all while working behind the scenes.

Speaker 1

Okay, so this memory pointers project is showing us how variables can do double duty. They can store data and they can also act as pointers to other data.

Speaker 2

Exactly and something you'll see a lot in ce and C plus plus plus a. It allows for some really efficient and creative ways to write code.

Speaker 1

It's like those multi tools that can be a screwdriver, a bottle opener, and a wrench all at the same time.

Speaker 2

That's a great analogy. It's all about having the right tool for the job, and pointers can be incredibly versatile.

Speaker 1

But as we've seen, there's also potential for danger if they're not used carefully.

Speaker 2

Absolutely misusing pointers can lead to all sorts of headaches, from programs crashing to those really tricky bugs that are hard to find and fix.

Speaker 1

So it seems like it takes a skilled hand to wield those pointers effectively.

Speaker 2

It does, and that's why having a good understanding of how memory works, how addresses work, and how pointers work is so important for programmers. It's the foundation for building reliable and efficient software.

Speaker 1

Now we've covered a lot of ground today, haven't we. We talked about memory registers, those mysterious pointers, how thirty two bit and sixty four bit systems work, and even how variables can be used as pointers.

Speaker 2

It's been quite a journey. Hope listeners have a new appreciation for how all of this works together to make our technology tick.

Speaker 1

I know, I've learned a ton and I'm not even a programmer. It's amazing to think about all of this complexity happening behind the scenes every time we use our devices.

Speaker 2

It really is. And remember, we've only scratched the surface here. There's so much more to learn about computer architecture, operating systems, and all the amazing things you can do with software.

Speaker 1

So keep those brains buzzin, folks. There's always more to explore.

Speaker 2

Exactly, and who knows, maybe one of our listeners will be the next brilliant mind designing the technology of the future.

Speaker 1

Well that's all the time we have for today. Thanks for joining us for this deep dive into the world of ARM sixty four. We'll be back soon with another exciting topic to explore,

Transcript source: Provided by creator in RSS feed: download file
For the best experience, listen in Metacast app for iOS or Android