سؤال

According to Encyclopedia Britanica assembly language is

mostly of symbolic equivalents of a particular computer’s machine language.

If this is true why do assemblers like GAS output files with headers?

I am certain that the ELF/ Mach-O/ PE headers are not "machine language".

So why don't assemblers just assemble the assembly language and leave formatting the binary up to the linker?

هل كانت مفيدة؟

المحلول

Problem is that the machine runs straight assembly but the operating system has to set up a place for the binary to execute. This is why you have things like ELF headers. Your OS needs to know where the code is, BSS section, where to load data, etc.... Without this information the OS cannot correctly load that if you just give it raw assembly.

If you have assembly code with inline data (coded into the instructions) then you could say that headers are unnecessary but that's rarely the case.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top