The state of Twitter programmers

The state of Twitter programmers
>inb4 Twitter programmers

>2^64 bytes of memory on x86
>NULL isn't a valid address for memory access

Attached: D7c5ukNXkAAZuKA.jpg (1200x783, 189K)

Isn't the real address of 0x0 memory mapped by the BIOS?

Not to the program. What the program sees is "virtual memory". Basically paged addresses laid out for it by the operating system. Nearly all OS's map the page at 0x0 to something usable, since programs expect to at least be able to read 0x0.

0x0 has to be readable, because NULL is (often) defined as a void pointer to 0x0. Meaning, NULL->NULL (null should point to null, but this requires 0x0 to be readable, and present in the virtual memory map).

No, the first megabyte of memory is RAM on x86. But most OSes map this segment as protected for the obvious reason as catching NULL pointer exceptions (as general protection faults).

Also, this >0x0 has to be readable
Actually no, dereferencing a NULL pointer should also lead to a segmentation fault.
int a = *((int*) NULL); // this should lead to a segmentation fault

Null pointer exceptions are a high-level concept tho. Reading 0x0 and therefore NULL is legal. C programs get a SEGFAULT when they touch an invalid page which usually only happens when another type of check fails.

>programs expect to at least be able to read 0x0
wut

>Null pointer exceptions are a high-level concept tho
They're not, they are triggered by hardware.

>Reading 0x0 and therefore NULL is legal
Usually no. See >C programs get a SEGFAULT when they touch an invalid page
Yes, correct. That's why the the lower end of memory is mapped but protected.

>2^64 bytes of memory on x86
current implementations only provide 48bits, but the standard does allow for a 64bit implementation

Was meant for

Yeah my bad. Was working on my own OS where I *did* map 0x0 in VM. I just realised that other OS's don't tho.

Attached: 1c73c31d.png (406x452, 29K)

@71139247
ultracringe

>assuming it will crash
And that's how you get fucked by undefined behavior.

The first 1KiB is IVT
0x400 is BDA
and so on
Accessing REAL memory around 0x0 is a very stupid idea

>0x0 has to be readable
>Reading 0x0 and therefore NULL is legal.

#include
#include

int main()
{
int a = *((int*) NULL);
fprintf(stderr, "Value of a=%x\n", a);
return 0;
}


There's nothing preventing you from doing that. :)

Here's a fun fact, the macOS loader has a segment that is called SEG_NULL which maps the lower part of memory as non-writable and non-readable. I found this out when messing with the loader code on macOS and trying to reverse engineer a way of making minimal Mach-O binaries.

Attached: Screenshot_2019-05-27_14-14-27.png (733x465, 50K)

IVT and BDA is only relevant when running in 16-bit real-mode. IVT becomes the IDT and BDA can be safely overwritten in protected/long mode.
Interesting.

Holy shit nobody fucking cares, take your outrage bait back to /b/ or /trash/

SMM is still running when in protected mode and requires EBDA. it is mapped ~500k

what is this creature

Attached: iZAxk4qr_400x400.jpg (400x400, 26K)

That's a gender-fluid mutt

an american

>outrage
>bait
>coping this hard
19 replies in 37mins
Stay mad feggit

Attached: 6d9947bf.png (650x840, 856K)