News for hackers. Stuff that matters.
Re:C Is Not a Low-Level Language by nerdponx on Tuesday May 01, 2018 @12:14PM (#16968370)
On the flipside, doesn't it allow more or less direct memory access?
Re:C Is Not a Low-Level Language by abofh on Tuesday May 01, 2018 @12:20PM (#16968463)
I mean, yes, no, it depends on what you mean?

You can write to null in C, your operating system rejects it. You can write past your allocated memory, your OS rejects it. It's not like just because it's written in C it gets to read the kernel memory - it's just that you can try.

All memory access in userspace is mediated by the MMU, so nothing in C gets "direct" memory access - but it does allow you to screw up your own memory space pretty well... I'm not sure that's C's fault though

Re:C Is Not a Low-Level Language by pjmlp on Tuesday May 01, 2018 @12:40PM (#16968679)
Many C targets also run bare metal, there is nothing to reject there, unless the hardware has an MMU and the code bothered to configure it on boot.
Re:C Is Not a Low-Level Language by nerdponx on Tuesday May 01, 2018 @01:56PM (#16969490)
That's my whole point. C doesn't try to stop you from doing that. C tries to do exactly what you ask it to, and if the OS doesn't allow it it just crashes.

To me that is about as low level as you can get without bypassing the OS.

Re:C Is Not a Low-Level Language by ryao on Tuesday May 01, 2018 @05:57PM (#16972102)
Try using atomic instructions or initializing various tables during system boot. You will find that there are things C cannot do, unless you write assembly and call to it from C.
Re:C Is Not a Low-Level Language by saagarjha on Tuesday May 01, 2018 @12:46PM (#16968734)
But is there really any programming language that lets you write to arbitrary memory? This is a problem of privileges rather than how low level your language is: it's not like you can write assembly that will give you arbitrary access to kernel memory.
Re:C Is Not a Low-Level Language by billfruit on Tuesday May 01, 2018 @02:00PM (#16969554)
In writing h kernal modules in C for vxworks, I find people quite often write/read data from hard-coded memmory addresses.