All Questions
6,262
questions
0
votes
0
answers
25
views
When an embedded c program is created, why is there extra machine code around my compiled c program?
This C program blinks an LED attached to an AVR ATmega32u4.
ISR(TIMER1_OVF_vect) // attach Interrupt Sub Routine to TIMER1
{
// toggle LED
PIND = (1 << PIND5); // #define PIND (*(...
0
votes
0
answers
43
views
signal SIGSEGV: address access protected in __run_exit_handlers
I'm trying to do a packer project for my school, it is made in C and ASM, and for the moment it is supposed to target only ELF files.
I have managed to do my section injection, correctly align my new ...
-1
votes
0
answers
53
views
Why does gdb combine byte values when examining memory as words? [closed]
While examining 4 addresses from $rip as bytes in GDB, it shows 4 individual values. However, when I examine the same addresses as words, it combines that 4 byte values into a single word value. Why ...
1
vote
1
answer
56
views
What are the binary representations for the flags used in the Linux open() syscall?
I am learning NASM and currently unsure what values should be used for the flags argument for open() as shown in the man page. I'm mainly asking this for clarification so I don't mess something up, ...
1
vote
1
answer
82
views
What is the difference between these two functions in x64 assembly?
I'm playing around with lower level stuff in C on Windows (x64) to try and learn low level concepts. I ran across something I don't understand and just wonder if someone could explain something to me....
3
votes
0
answers
51
views
How to pass arguments to a windows syscall in NASM assembly? [duplicate]
I am learning how to implement direct system calls using nasm assembly and c code, I have created a funcs.asm that contains
section .text
global NtOpenProcess
NtOpenProcess:
mov rax, 26h
...
1
vote
1
answer
89
views
Why do I get multiple ASM instructions per addition? (Visual Studio 2022 Community)
Here's the C program, I use Visual Studio Community 2022 with MSVC compiler. What are all those mov instructions, I don't use any compiler optimization flags.
#include <stdio.h>
int main(void) {...
1
vote
1
answer
44
views
E2028: _small_code_ is an undefined reference
I am working on my own bootloader. I want it to print "Hello world". For some reason, I get an error: Error! E2028: small_code is an undefined reference
Hello! I am working on my own ...
2
votes
0
answers
76
views
How does this assembly code perform the source code b = a/3 when a = 2? [duplicate]
I'm trying to trace this C source code (when a = 2):
b = a/3;
To this ARM assembly code (for unsigned 1 byte value):
ldrb r2, [fp, #-6] @ zero_extendqisi2 @ tmp162, a
ldr r3, .L34 @ tmp164,
...
2
votes
0
answers
55
views
Native API Processor information
When I send the first parameter as 1, i.e. SystemProcessorInformation via the ntdll!NtQuerySystemInformation function, I get the output:
Processor Architecture: 9
Processor Level: 25
Processor ...
0
votes
0
answers
99
views
By default compiler generates assembly code or object code [duplicate]
In conpiler design, in books, it is written that compiler generates assembly code then assembler convert that assembly code into object code.
But assembly code is not used, so todays compiler ...
0
votes
1
answer
73
views
Unresolved external symbol happend when compiling C++
im trying to make a super simple direct syscall. I have 2 file, 1 is the asm file and 1 is the main source file. The ASM look likes:
EXTERN wNtAllocateVirtualMemory: DWORD
.CODE
...
-4
votes
0
answers
108
views
Why does the first code cause a segmentaiton fault while the later one doesn't?
I'm self-studying csapp, and currently stuck at level-3 of Attack Lab. This lab requires you to
inject some code by a 40-byte input string. The basic idea is that you input a 48-byte string,
with the ...
1
vote
1
answer
71
views
LLVM IR: ".s" file vs ".ll" file vs ".bc" file
I read that the '.ll' file is equivalent to the '.bc' file except that '.ll' is more human readable. But is '.ll' machine independent? I see references to x86_64 in my '.ll' file. In my '.s' file I ...
2
votes
2
answers
102
views
Why is the assembly code generated with gcc under windows unable to be assembled under WSL?
I learned that assembly code doesn't depend on the OS. For verification, I generate the assembly code of the following code snippet (named test.c) under windows and try assembling it under WSL.
int ...