x86-64 is a 64 bit instruction set, backwards compatible with the 16 and 32 bit architectures originating from the Intel 8086 processor.
1
vote
1answer
14 views
Performing a Backspace in YASM or NASM assembly
I have a program reading characters in raw mode. That is, any characters input are read immediately instead of being buffered.
I would like to know how to perform a backspace. That is, when I press ...
16
votes
2answers
186 views
How does malloc work in a multithreaded environment?
Does the typical malloc (for x86-64 platform and Linux OS) naively lock a mutex at the beginning and release it when done, or does it lock a mutex in a more clever way at a finer level, so that lock ...
2
votes
1answer
46 views
LD_PRELOAD not working with my program
For testing LD_PRELOAD, I wrote my own getpid, which prints something before calling the original getpid using dlsym. The code is given below.
#define _GNU_SOURCE
#include <unistd.h>
#include ...
2
votes
1answer
37 views
Called object is not a function with function pointer
I have the following code.
typedef pid_t (*getpidType)(void);
pid_t getpid(void)
{
printf("Hello, getpid!\n");
getpidType* f = (getpidType*)dlsym(RTLD_NEXT, "getpid");
return f(); // ...
1
vote
1answer
54 views
How to include *.so file in makefile
For a program I was linking the static glibc library (which I modified). My makefile looks something like this.
CXX = g++
CXXFILES = main.c
CXXFLAGS = -g -o prog -D_GNU_SOURCE
LIBS = ...
6
votes
2answers
122 views
Is this is a good way to intercept system calls?
I am writing a tool. A part of that tool will be its ability to log the parameters of the system calls. Alright I can use ptrace for that purpose, but ptrace is pretty slow. A faster method that came ...
1
vote
1answer
20 views
LD_PRELOAD and extern variables
Say, I want to modify mmap. So I create a new shared object file for that purpose and use LD_PRELOAD to use it instead of the original mmap. However, I need to refer to a variable which is my program ...
3
votes
3answers
83 views
Meaning of double underscore in the beginning
In the standard library (glibc) I see functions defined with leading double underscores, such as __mmap in sys/mman.h. What is the purpose? And how can we still call a function mmap which doesn't seem ...
0
votes
0answers
66 views
I can't find mmap function in glibc
I am using my own modified glibc library. One functionality I want to add, is to log system call parameters. Instead of modifying the system calls in the kernel, I'm trying to log the parameters in ...
1
vote
1answer
53 views
No line number found known for in gdb
I have compiled my own glibc, which produced libc.so. I loaded the libc.so file in gdb by doing gdb -q ./libc.so. However, when I try to find the location of a function by doing list function_name, I ...
4
votes
2answers
52 views
2
votes
2answers
74 views
How to know the location of a function being compiled by the compiler
I am trying to modify glibc to use with my program. I wanted to add some code to the mmap function (Not the mmap system call, but the function in glibc which performs the mmap system call). However, I ...
2
votes
1answer
45 views
Is there any interactive tool on web to understand common code bases?
I am modifying the code for glibc 2.5. Now since glibc is large and complex, I need to have a really good tool, to see interaction of different parts of the code. I am using Understand for this ...
2
votes
1answer
64 views
How to start two instances of a process through fork without modifying the program
I am trying to fork a process from another at the start. For this I tried to modify the __libc_start_main function in glibc (a modified glibc that I use) and tried to put the fork there, but could not ...
3
votes
1answer
99 views
How to refer to a variable declared inside a static library?
I am trying to use a modified glibc library. The glibc library is statically linked to my code. I have declared a new variable (lets call it my_libc_var) in the glibc library. However, when I try to ...