gcc

how to link to shared lib from shared lib with relative path

Hello. I'm working on a Firefox plugin that uses external libraries to render 3D graphics on the browser. The problem is that i want the plugin to use external libraries packed with it without changing the LD_LIBRARY_PATH variable. The libraries are installed in a position relative to the plugin (a shared library too), while the actual...

gcc option: get start and end addresses of inline functions

My question is clear: How to get the compiled instructions for inlined functions when using -O2? I tried readelf to get the mapping between the source code lines and the binary codes addresses. But there is no mapping at all for the line where the inlined function is called. So, what compiler option or any approach could be used? In f...

Why does gcc not implicitly supply the -fPIC flag when compiling static libraries on x86_64.

I've had numerous problems compiling shared objects that link statically against static libraries. This problem only shows up on x84_64 platforms. When doing the same compilation work on x86_32 I do not have any problems. Perhaps this is a OS specific GCC configuration thing, but my research indicates that its how GCC works on x86_64 p...

gdb: how does it get the information of the executable?

We can set breakpoint at a func, hence gdb knows the entrance and exit address of a certain function. But how does it get this information? Does it uses DWARF or readelf for the executable, if yes, how? Thanks ...

how to set control register 0 (cr0) bits in x86-64 using gcc assembly on linux

I am using the following code to set the cr0 bit to disable cache. When I compile this #include <stdio.h> int main() { __asm__("pushl %eax\n\t" "mov %cr0,%eax;\n\t" "orl $(1 << 30),%eax;\n\t" "mov %eax,%cr0;\n\t" "wbinvd\n\t" "popl %eax"...

C++'s default inheritance access specifier?

I have some legacy code that I have to wrap, and I have come across this declaration: class Foo : Bar { // ... }; This seems to compile under GCC. I know it's bad, but I can't change it. My question is, if no inheritance access specifier is present, how does the C++ compiler handle it? ...

Precedence of -D MACRO and #define MACRO

If I have a C file foo.c and while I have given -DMACRO=1 as command line option for compilation. However, if within the header file also I have #define MACRO 2 Which of these will get precedence? ...

How to move GCC in osx from xcode to /usr/bin

I have the gcc compiler in "/Developer/usr/bin/gcc" but when i type in gcc into terminal it says can not be found, i assume this is because its not in the "/usr/bin" dir. So can i a) move gcc from the first dir to the second, or set some kind of shortcut pointing gcc to "/Developer/usr/bin/gcc" ...

Is it possible to do hot code swapping in C ?

this en.wikipedia.org/wiki/Hot_swapping#cite_note-1 says that VS can do it with the help of its debugger. Does gdb provide a similar functionality ? this is the closest i could find, but doesn't seem to be ready to be used: http://www.aitdspace.gr/xmlui/handle/123456789/219 dlopen/dlsym/dlclose are also close, but will not work for ...

Eclipse CDT Debugging (An External Process) and Finding Its Source Code

When I attempt to debug a external process with Eclipse CDT, I'm able to attach to it, but I cannot get the debug configuration to find the original C source. When I launch the debugger with the process running within Eclipse, I can get the debugger to find the source code. It is only when attaching to an external process that CDT doesn...

cross compile (arm-none-eabi-as) arm assembly error "junk at end of line /" or undefined symbol

Hi while i cross compile an startup.s file (arm-none-eabi-as file.s) (*-gcc) I am getting in each commentary line some errors - junk at end of line, first unrecognized character is / when i delete the // some comment lines i get errors about undefined symbols even i defined them at beginning of the file. anyone know whats wrong? ...

No Matching Function - Specialized Signature hiding Generic?

Hello, I just got stuck with the following C++ compiler error: no matching function for call "EPTDerivedException::HandleClass( BaseClass& )" candidates are: void EPTDerivedException::HandleClass( DerivedClass ) I cannot explain this, because there should be a function HandleClass( BaseClass ). This is the calling code: BaseClass oB...

Create a program which utilizes 2 different ISAs

Hello newcomer here (be gentle), I am attempting to write a program which has floating point code in it. However this program needs to run on 2 different processors. Which have roughly identical ISAs except for their floating point model. They use completely different instructions and registers to do floating point calculations. Wha...

Debugging slow functions in C programs (built by gcc)

Having source like this: void foo() { func1(); if(qqq) { func2(); }; func3(); func4(); for(...) { func5(); } } I want to obtain info like this: void foo() { 5 ms; 2 times; func1(); 0 ms; 2 times; if(qqq) { 0 ms; 0 times; func2(); 0 ms; 2 times; }; 20 ms; 2...

How to eliminate preprocessor warning about pasting certain tokens

Is it possible with gcc to eliminate the warning below without eliminating all warnings? pasting "/" and "/" does not give a valid preprocessing token For a certain platform, I must use a specific cross-compiler, but I can use make, so I use gcc to create the dependencies. I know that I'm passing the “//” token to the compiler and it’...

How to tell gcc to instrument the code with calls to my own function each _line_ of code?

For example, there is the source: void my_special_debugging_function(const char* function_name, const char* file_name, int line_number); void func1() { func3(); func4(); } void foo() { func1(); if(qqq) { func2(); }; func3(); func4(); for(...) { func5(); } } It should compile as: v...

error while using regex_replace function from <tr1/regex>

#include <string> #include <tr1/regex> #include "TextProcessing.h" const std::string URL_PATTERN("((http://)[-a-zA-Z0-9@:%_\\+.~#?&amp;//=]+)"); const std::string REPLACEMENT("<a href=\"$&\"\">$&</a>"); std::string textprocessing::processLinks(const std::string & text) { // essentially the same regex as in the previous example, b...

what's the ELF object file size limitation on 64bit platform?

Assume the x86 64 and linux platform. If you look into the ELF header, the offset are all 64bit. So it's easy to create an object file larger than 4G with relocatoin R_X86_64_64. This means a static .o file and executable can be as large as 64bit can represent. However, for shared library, like gcc , we only have R_X86_64_PLT32 reloca...

how to get the x to the pow y in C under c99 standard

I have #include<math.h>, and I tried to use pow(x, y) and powf(x, y). but it seems neither of them are under c99 standard. and I use the command gcc -std=c99 test.c -o test to compile. what function there exists I can use? ...

How to "interleave" C/C++ souce with my string (only inside functions at appropriate places)?

For example, there is the source: void func1() { func3(); if(qqq) { func2(); } func4( ); } It should be transformed to: void func1() { MYMACRO func3(); MYMACRO if(qqq) { MYMACRO func2(); MYMACRO } MYMACRO func4( ); MYMACRO } I.e. to insert "MYMACRO\n" at the end of each line...