Linked Questions
2 votes
0 answers
346 views
How is an instruction executed in a flat memory model, when both the instruction and the accessed data are located in the same page in memory? [duplicate]
The second paragraph in Section 3.2.1 Basic Flat Model in "Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3" has the following sentence: To implement a basic flat ...
112 votes
3 answers
56k views
What's the difference of section and segment in ELF file format
From wiki Executable and Linkable Format: The segments contain information that is necessary for runtime execution of the file, while sections contain important data for linking and relocation. Any ...
8 votes
5 answers
3k views
How does the CPU know how many bytes it should read for the next instruction, considering instructions have different lengths?
So i was reading a paper, and in it, they said that statically disassembling the code of a binary is undecidable, because a series of bytes could be represented as many possible ways as shown in ...
8 votes
3 answers
9k views
Fully understanding how .exe file is executed
Goal I want to understand how executables work. I hope that understanding one very specific example in full detail will enable me to do so. My final (perhaps too ambitious) goal is to take a hello-...
6 votes
3 answers
4k views
Copying EAX to RAX higher bits?
I am wondering if there is any sequence of instructions without use of any other register to copy the lower 32 bits of RAX to its higher 32 bits. Of course, I want EAX intact as well. Preferably ...
5 votes
2 answers
4k views
What is the reason for having read-only data defined in .text section?
I am learning assembly and low-level programming itself and reading a book about it. It is said there that we can put any data inside the .text section of an elf file but of course we can't mutate it ...
9 votes
1 answer
2k views
How does an instruction decoder tell the difference between a prefix and a primary opcode?
I'm trying to wrap my head around the x86 instruction encoding format. All the sources that I read still make the subject confusing. I'm starting to understand it a little bit but one thing that I'm ...
4 votes
2 answers
1k views
Assembly function address table and data under the function or in data section
I have a question about putting data (address table or other data) in the .text section under its function or put in .data section? For example, I have a function like this : extern int i0(); extern ...
0 votes
2 answers
3k views
NASM module to convert hex into string and print it out. Assembles but not working as expected
I am trying to write a simple assembly code to spit out hex values to the screen. There are two files print_screen.asm which is working with other modules. I think the problem is in my logic when ...
1 vote
1 answer
2k views
Assembly - Can I declare variables inside a Procedure?
Well the question is straightforward. I want to know if declaring variables inside procedures is a okay thing to do. like this for example: SAMPLE PROC NEAR ; PROC BODY RET VARIABLE DW 0000H ...
2 votes
1 answer
862 views
Is TLB inclusive?
Is TLB hierarchy inclusive on modern x86 CPU (e.g. Skylake, or maybe other Lakes)? For example, prefetchtn brings data to the level cache n + 1 as well as a corresponding TLB entry in DTLB. Will it ...
1 vote
2 answers
1k views
What happens if `objdump -d --start-address` starts printing from the middle of an x86 instruction?
... in other words, is x86-64 a uniquely decodable code that, no matter where I start decoding it, always eventually yields the correct disassembly code? Let's say this (the ground truth) is what part ...
4 votes
2 answers
432 views
Where does the asm code during the debugging process in GDB come from?
Basically, according to my knowledge, If we use GDB to debug execute code compiled from C source code, compiler will leave the source code Path in the ELF/PE file, so GDB will use the source code ...
0 votes
0 answers
1k views
Easily retrieving labels in gdb
I have defined an array in asm as: arr: .word 1,3,9,27 And now that I'm in gdb, the current way I'm using to find and print that array is looking for the instruction that looks like it might include ...
3 votes
1 answer
478 views
Strategy for AMD64 cache optimization - stacks, symbols, variables and strings tables
Intro I am going to write my own FORTH "engine" in GNU assembler (GAS) for Linux x86-64 (specifically for AMD Ryzen 9 3900X that is siting on my table). (If it will be success, I may use ...