Questions tagged [gcc]

GNU Compiler Collection, it includes front ends for C, C++, Objective-C, Fortran, Java, Ada, and Go, as well as libraries for these languages (libstdc++, libgcj,...).

Filter by
Sorted by
Tagged with
1 vote
1 answer
172 views

Why this x64 shellcode doesn't work?(segmentation fault)

I found a simple shellcode on the internet. Then, to test this shellcode, I make the simple ret overwrite code. test.c #include <stdio.h> #include <string.h> char buf[100]; int main(void)...
doldom's user avatar
  • 55
5 votes
1 answer
124 views

Zlib structure inside a GCC static library

I'm trying to analyze a GCC static library which is a part of a commercial software. First, I used IDA Pro to analyze entire Lib file, but it could find only object files and was unable to disassemble ...
HamidReza's user avatar
  • 151
0 votes
1 answer
292 views

Output from gcc containing all included source code?

Right now, I'm using a combination of gcc -g and the objdump -S modes to generate assembly code with debug source code interleaved. However, I'm having trouble correlating some of the functions that ...
dingo_kinznerhook's user avatar
1 vote
0 answers
90 views

What change to the source code would produce an LT compare rather than an OLT compare in MIPS assembly?

I need some help reverse engineering a function in MIPS assembly. It was compiled for the PlayStation 2's EmotionEngine CPU. My goal is to produce a matching decomp of the function; it is the proof-of-...
Zac's user avatar
  • 11
2 votes
0 answers
164 views

What hints can x86 disassembly give as to GCC/G++ compiler version and options?

I've taken an interest to disassembling binaries and attempting to recreate 1:1 source code (logic) in C and C++ compiled with GCC. I say "logic" because this question does not pertain to ...
Matthew Tingum's user avatar
1 vote
1 answer
380 views

How to locate memory address in register $esp

000011d9 <main>: 11d9: 8d 4c 24 04 lea 0x4(%esp),%ecx 11dd: 83 e4 f0 and $0xfffffff0,%esp 11e0: ff 71 fc push -0x4(%ecx) 11e3: ...
user40564's user avatar
1 vote
0 answers
63 views

Is disassembly of standard gcc programs trivial, or just as difficult as video game ROMs?

I am attempting to do some reverse-engineering of ARM binaries, with the ultimate goal of reverse-engineering GBA ROMs. Of course, GBA ROMs contain a mixture of code and data, so a standard ...
JBraha's user avatar
  • 133
1 vote
0 answers
151 views

silvio packer for shared libray leads to error: "ELF load command address/offset not properly aligned"

I'm trying to implement a packer based on silvio infection. The packer works fine for ET_EXEC. However, it failed with "ELF load command address/offset not properly aligned" error for the ...
prgbenz's user avatar
  • 81
1 vote
0 answers
69 views

failed to trigger packer's loader by overwritting the entry of rela.dyn on aarch64

I have implemented packer of x86_64 shared library. Briefly, a loader is injected to a shared library, and the rela.dyn entry is modified such that it points to the address of the loader. Once the ...
prgbenz's user avatar
  • 81
2 votes
0 answers
229 views

How can I tell ld to link to a local symbol in a shared object?

Symbols in shared objects can be either local or global. This is controlled by a flag in the symbol table. If the symbol is local, ld won't resolve to it. Reverse engineering can often be aided by ...
SRobertJames's user avatar
2 votes
1 answer
3k views

How to disable relro while compilation?

My doubt is how to compile the binary without RELRO? and why it is enabling FULL-RELRO when we are not providing any flags? This is the code. #include <stdio.h> #include <stdlib.h> int ...
neeraj's user avatar
  • 33
2 votes
1 answer
276 views

Comparing the static address of the vtable of a class, to the pointer to it held by the object

I know this is compiler/ABI dependent, not necessarily standardized, etc. I've always assumed, from what I've read in several places (e.g. an answer here or the example in wikipedia), that a typical ...
Alejandro Exojo's user avatar
2 votes
2 answers
413 views

Changing value of parameter with gdb

I have a file named exploit.c inside which: #include <stdbool.h> #include <stdio.h> const char y1 = 'a'; const char y2 = 'b'; const char y3 = 'x'; const char y4 = 'y'; const char y5 = 'i';...
Mark Ezberg's user avatar
0 votes
0 answers
81 views

Radare2 is showing weird disassembly as compared to disassembly of gcc

Today i was playing around with c code in r2. I compiled a file which had the following code. #include <stdio.h> int main(){ int a=9; float b=1.1; int sum; sum = ...
Mr. rc's user avatar
  • 45
0 votes
2 answers
224 views

What is the first argument (rdi) to operator+ on x86_64 SystemV?

I'm looking through a block of disassembled C++ which works with several std::string instances. I had been confused by several calls to various versions of std::operator+, but this call seems ...
MTCoster's user avatar
  • 137
0 votes
1 answer
888 views

main function not found in GCC compiled code

I'm trying to learn reverse engineering using Radare2. For this I compiled a hello world program with GCC on Ubuntu (version: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0). #include <stdio.h> int ...
martsc1's user avatar
0 votes
1 answer
68 views

What is the use of moving a variable 3 times only to pass it back to the original register, with no calculations in between?

I'm reverse engineering a C++ binary using IDA, and there's one function that I don't quite understand. x = dword ptr -8 var_4 = dword ptr -4 push rbp movss rbp, rsp sub rsp, 10h movss [...
Magusviper's user avatar
0 votes
1 answer
2k views

How to find function start in stripped binary?

Given C code, are the function addresses from the ELF the same as those in the stripped version? I don't have any specific code in mind. Just trying to learn in general how to find the function ...
Steven's user avatar
  • 103
0 votes
0 answers
159 views

Force gcc to use more complex instructions

I am reverse engineering a piece of assembly. I am trying to write the equivalent code in C, however, when I compile my code, gcc prefers to use simple instructions instead of the complex ones that ...
Bat's user avatar
  • 101
1 vote
1 answer
243 views

GCC is not recognizing symbol table in my hand-made ELF file

For learning purposes I've created (using a hex editor and some macros) the following ELF file: hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped xxd hello.o: 00000000: ...
PhilipRoman's user avatar
1 vote
2 answers
350 views

Detecting and solutions of stack smash protection

This video https://youtube.com/watch?v=4HxUmbOcN6Y presents how modern compilers protect stack overflows with stack cookies and function __stack_chk_fail. How can one identify if a binary has stack ...
wfj96649BcaooCom's user avatar
2 votes
1 answer
298 views

Arrangement of variables on the stack - out of order?

I was practicing some reverse engineering crack-mes as part of our university curriculum, and I have a question around the arrangement of variables on the stack. I have a very basic C++ code, like ...
user148898's user avatar
1 vote
3 answers
13k views

Use GCC and objdump to disassemble any hex to assembly code

What would be the best way (also fewer steps) to generate assembly code for a given hex code ? For e.g., if we know the architecture is x86, and given hex value 0x55, what is the best way to generate ...
tecMav's user avatar
  • 111
1 vote
2 answers
157 views

Strings weirdly split in binary

Recently I have come across a few parts in a binary that looked odd to me, and I wanted to ask if this is something common compilers do, and if there is a way to undo it. (The binary is from a raw ...
Lukas S.'s user avatar
1 vote
1 answer
789 views

Find functions names in .init_array section in unstripped library

Is it possible to find out all instances of static initialization in a elf dynamic library. I can dump the array of function pointers in .init_array section via objdump command like this. objdump -s -...
Arpit Aggarwal's user avatar
1 vote
1 answer
135 views

Unknown parameters in custom signal handler on Linux

0x0000000008001946: mov 0xa8(%rdx),%rax 0x000000000800194d: lea 0x28(%rdx),%rsi 0x0000000008001951: lea 0x2(%rax),%rdi 0x0000000008001955: add $0xe,%rax 0x0000000008001959: ...
Omniscient Phynial Sniper's user avatar
1 vote
0 answers
63 views

GCC adds code involving `ecx` in main? [duplicate]

I have two pieces of code, one of which is compiled by me the other of which is supplied in binary-only. The code I am compiling has added instructions pertaining to ecx. What does this code do? The ...
Evan Carroll's user avatar
  • 1,769
1 vote
2 answers
6k views

Can't find the password anywhere in the binary

This is my first post here. I was recently involved in a capture the flag preparation test which involved decompiling an ELF 32-bit LSB executable, Intel 80386 file for Linux compiled with GCC. The ...
user avatar
2 votes
1 answer
2k views

How to override c++ string class with LD_PRELOAD

i am trying to override predefined functions such as strcmp, getenv, etc. i already override some of them using LD_PRELOAD options. but i can't override string class, how can i override c++ string ...
Mustafa Akdeniz's user avatar
2 votes
1 answer
317 views

What does __return_ptr do in IDA?

Let's say I have this program: struct A { int x; }; struct A func1(int z) { struct A result; result.x = z+1; return result; } int main() { return func1(1).x; } When compiling ...
Stefan Friesel's user avatar
3 votes
1 answer
303 views

Basic hello world stack manipulation troubles

I'm a beginner in reverse engineering, and as a beginner I started to read "Reverse Engineering for beginers". Here is the hello world program from the book (taken from chapter 3, page 12) : Now ...
Nark's user avatar
  • 281
7 votes
5 answers
2k views

How to find out if PE executable was compiled with gcc or VisualStudio?

I looked at two ways so far. Both did not convince me in regard to false positives or false negatives: Using strings: How to retrieve the GCC version used to compile a given ELF executable? Using the ...
langlauf.io's user avatar
  • 1,540
1 vote
1 answer
1k views

How do you compile a C program with missing symbols?

In Learning Linux Binary Analysis by Ryan "elfmaster" O'Neill. On Page 33, the author compiles a program with a symbol reference and no definition, Let's take a look at the source code: _start() ...
Evan Carroll's user avatar
  • 1,769
-1 votes
1 answer
685 views

Shells CTF segfault - wrong address

PicoCTF 2017 Shells I have a binary and source: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/mman.h> #define AMOUNT_OF_STUFF 10 //TODO: Ask IT ...
duch4ever's user avatar
1 vote
2 answers
3k views

newbie trying to understand disassembled code

I have been writing small C programs and then disassembling them to try to understand what is actually happening under the hood. I am using mingw-w64 on Windows 7 for my work, and I have run into a ...
dnraikes's user avatar
  • 379
2 votes
2 answers
5k views

Changing Entrypoint in ELF executable

I wrote some code that does the following: Searches for and finds an offset in a binary file to add code (looks for a sequence of 00s I can overwrite). Then, I change the entrypoint of the ELF to ...
joe's user avatar
  • 29
10 votes
2 answers
5k views

What is the purpose of these instructions before the main preamble?

I wrote a small C program below: #include <stdlib.h> int sub(int x, int y){ return 2*x+y; } int main(int argc, char ** argv){ int a; a = atoi(argv[1]); return sub(argc,a); } Compiled ...
drdot's user avatar
  • 279
2 votes
0 answers
917 views

How can I control local variable ordering on stack in gcc?

I am writing a reversing challenge where I need to seed a bug. It's important to have a particular ordering of local variable on stack in a method. However, gcc seems to shuffle those around. How can ...
sherlock's user avatar
  • 1,351
3 votes
1 answer
3k views

GCC change the order of variable declaration

I have this very simple piece of code: // test.c int main(){ int a = 0; char b[10]; int c = 0; return 0; } Compiled with gcc (6.2.1): $ gcc -g -o test test.c And analysed with gdb: $ gdb ...
nobe4's user avatar
  • 199
1 vote
1 answer
5k views

Passing argument through registers instead of the stack

I'm learning (and re-learning) C and assembly, and I came across a difference between what I've been taught and the actual result I have. Some code: int test(int a, int b){ return a + b; } int ...
nobe4's user avatar
  • 199
1 vote
2 answers
1k views

C/C++ to Assembly language

Is there any book or articles related to how C/C++ code is converted to assembly language, I mean common patterns for a specific compiler, etc?
J. Doe's user avatar
  • 95
1 vote
1 answer
822 views

C++ to assembly, GCC vs CL

I have following C++ code: int main(){ int a = 1; double d = 1.2; return 0; } and get the following assembly using GCC 6.2 -m32: main: lea ecx, [esp+4] and esp, -8 ...
Person.Junkie's user avatar
0 votes
1 answer
1k views

Fixing weird no-sections embedded ELF binary for decompilation

I recently stumbled upon a weird binary, complied by a "Qualcomm Hexagon" compiler. The ELF binary seems fine, however section tables (section header size and string table index) seem empty. For those ...
Ömer's user avatar
  • 11
0 votes
0 answers
383 views

How to pass Obfuscated Elf binary to gcc optimization end

Currently I have a 2000+Line function to reverse engineer with many redundancies and appears to be obfuscated. It their a way to pass to pass this binary to gcc or clang to reassemble it and optimize ...
u185619's user avatar
  • 335
1 vote
1 answer
635 views

Problem to understand execution of payload (shellcode)

I know that there are lot of (good) tutorials regarding this topic, but after reading them, I really cant follow their thoughts (e.g.: Smashing The Stack For Fun And Profit): The problem is that we ...
JDoens's user avatar
  • 63
1 vote
1 answer
667 views

What is the difference between these two function prologue instruction sequences?

the test is on 32-bit x86. I compiled the code with gcc 4.2, optimization level o2. I compiled the C code into binary, and then use objdump to disassemble it. Here are two sequences of instructions ...
lllllllllllll's user avatar
1 vote
3 answers
989 views

Without push instructions [duplicate]

If I pass an argument to a function, it should be translated in assembly language into push something. I coded the following in C: #include <stdio.h> int sum(int a, int b,int c) { int ...
user13458's user avatar
2 votes
1 answer
2k views

How to get the information of "how many and which symbols are resolved by linker"?

The test is on 32-bit Linux, x86. With gcc 4.6.3 and GNU ld 2.22. So I am trying to get the information of "how many symbols are resolved by linker" during link time? And how can I list the ...
lllllllllllll's user avatar
3 votes
2 answers
3k views

How can I write my main function as assembly opcodes in an integer array?

My OS is Windows 7 64-bit and my processor is an Intel Core i7-4700MQ running on the x64 architecture. My program is 32-bit. Recently, I read an article here describing how it is possible and legal ...
CaptainObvious's user avatar
1 vote
0 answers
102 views

VLAs in C++ - seemingly nonsential compiler code [duplicate]

I've been wondering, why all the hassle with variable length arrays (such as int x[n])? Theoretically, it's just another local variable, so it's merely a matter of subtracting the appropriate value ...
user4520's user avatar
  • 585