Menu
  • HOME
  • TAGS

Does breakpad's dump_syms tool handle gnu_debuglink sections?

Tag: gcc,objcopy,breakpad

I'm having a hard time generating breakpad symbols on Linux from stripped binaries.

I compile with:

gcc-4.4 -c -I../include -D_LINUX -m64 -fPIC -D__LP64__ -D_GNU_SOURCE -Wno-switch -Wno-missing-braces -fno-strict-aliasing -Wreturn-type -Wall -Wno-unknown-pragmas -Wno-parentheses -pipe -fmessage-length=0 -g -DRELEASE -O3 -o lin/voxl.o voxl.c -fvisibility=hidden

There are also some C++ files.

I then link with:

g++-4.4 -o ../liblin/foo.so -shared  <objects> <libs> -z origin -Wl,-R,\$ORIGIN -Wl,-rpath,../liblin

And finally strip debug information into .debug files with:

objcopy --only-keep-debug ../liblin/foo.so ../liblin/foo.so.debug
objcopy --strip-debug ../liblin/foo.so
objcopy --add-gnu-debuglink=../liblin/foo.so.debug ../liblin/foo.so

The resulting binary can be debugged with GDB with full symbol information. It contains a .gnu_debuglink section which refers to foo.so.debug (no dir path), which is correct.

However, dump_syms doesn't seem to be following the link, even though the code being edited in this patch strongly suggests that it should. I get this output in stderr:

liblin/foo.so, section '.eh_frame': the call frame entry at offset 0x18 uses a DWARF expression to describe how to recover register '.cfa',  but this translator cannot yet translate DWARF expressions to Breakpad postfix expressions
liblin/foo.so: file contains no debugging information (no ".stab" or ".debug_info" sections)

The resulting symbol file is 2MB, whether or not the .gnu_debuglink section is present in the ELF. When using this 2MB symbol file with minidump_stackwalk, the wrong functions appear on stack frames. When I run dump_syms on a binary with embedded symbols the output file is 9MB and stack frames are correct.

What am I doing wrong?

Best How To :

This turned out to be two things:

  1. To load symbols from external files you must provide a directory path to dump_syms, even if the symbols are in the same folder as the binaries. e.g. dump_syms foo.so .
  2. There is a bug in Breakpad that means external symbols will never be loaded even if they are found. I've submitted a patch to fix it.

Ambiguous reference to variable

gcc,fortran,fortran90,gfortran,intel-fortran

The inte is declared in both modules. Upd. The inte(y,beta,r2,r1) function is defined in the module in, and is used in the main program. This function requires four arguments, but this call irange=inte(intrange/division) provides only one argument. I'm not sure if this function should be used in this case. Try...

How can I convert an int to a string in C++11 without using to_string or stoi?

c++,string,c++11,gcc

Its not the fastest method but you can do this: #include <string> #include <sstream> #include <iostream> template<typename ValueType> std::string stringulate(ValueType v) { std::ostringstream oss; oss << v; return oss.str(); } int main() { std::cout << ("string value: " + stringulate(5.98)) << '\n'; } ...

How to have gcc warn about conversions from uint32_t to uint64_t?

c++,gcc,compiler-warnings

There is nothing wrong with that conversion because the a uint32_t being converted to a uint64_t will not alter the value: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wconversion-499 #include <iostream> #include <cstdint> int main(int argc, char *argv[]) { std::uint32_t i = 1; std::uint64_t j = 1; // warning: conversion to 'uint32_t {aka unsigned int}' from 'uint64_t...

How is shellcode generated from C? - With code example

python,c,gcc,assembly,shellcode

The problem with creating shellcode from C programs is not that you cannot control the assembly generated, nor something related with the code generation. The problem with creating shellcode from C programs is symbols resolution or relocation, call it whatever you like. You approach, for what I have understand, is...

__cplusplus < 201402L return true in gcc even when I specified -std=c++14

c++,gcc,g++,c++14,predefined-macro

According to the GCC CPP manual (version 4.9.2 and 5.1.0): __cplusplus This macro is defined when the C++ compiler is in use. You can use __cplusplus to test whether a header is compiled by a C compiler or a C++ compiler. This macro is similar to __STDC_VERSION__, in that it...

Dereferencing pointer to incomplete type error for struct member access in Python swig C wrapper

python,c,gcc,compiler-errors,swig

You declare this type: struct WFDB_siginfo and use this one: struct WFDB_Siginfo which is different (note the uppercase S), so gcc truly believes struct WFDB_Siginfo is another type which has not been declared yet....

c++ segfault on one platform (MacOSX) but not another (linux)

c++,linux,osx,gcc,llvm

This is a problem: ~Word() { index.erase(m_word); } // Remove from index static void DeleteAll() { // Clear index, delete all allocated memory for (std::map<std::string, Word*>::const_iterator it = index.begin(); it != index.end(); ++it) { delete it->second; } } delete it->second invokes ~Word which erases from the map that you are...

MinGW's ld cannot perform PE operations on non PE output file

gcc,assembly,mingw,nasm,osdev

Old MinGW versions had the problem that "ld" was not able to create non-PE files at all. Maybe current versions have the same problem. The work-around was creating a PE file with "ld" and then to transform the PE file to binary, HEX or S19 using "objcopy"....

Unclassifiable statement at (1) in Fortran

gcc,fortran,fortran90,gfortran

real(10) :: inte is not just a real scalar variable of kind 10, whatever that kind means for your compiler. (For gfortran kind 10 is the x87 extended precision, for many other compilers it is invalid.) When you then do integrand(i)=inte(x(i),beta,r2,r1) it makes no sense to index a scalar. If...

Can I have optimization on, but not suffer from reordered statements?

c,gcc

If you're using GCC 4.8 or above, try using -g -Og. As explained in the release notes: A new general optimization level, -Og, has been introduced. It addresses the need for fast compilation and a superior debugging experience while providing a reasonable level of run-time performance. Overall experience for development...

How to override C compiler aligning word-sized variable in struct to word boundary

c,gcc,struct,bit-packing

What you are looking for is the packed attribute. This will force gcc to not do any padding around members. Taken from the GCC Online docs: packed This attribute, attached to an enum, struct, or union type definition, specified that the minimum required memory be used to represent the type....

GCC on Solaris - parse error before `0x00000002'

c++,gcc,solaris

usr/include/iso/ctype_iso.h from Solaris 8 defines _L: #define _U 0x00000001 /* Upper case */ #define _L 0x00000002 /* Lower case */ #define _N 0x00000004 /* Numeral (digit) */ #define _S 0x00000008 /* Spacing character */ #define _P 0x00000010 /* Punctuation */ #define _C 0x00000020 /* Control character */ #define _B 0x00000040...

GCC emits vastly different code using “-march=native” on similar architectures

c,gcc,assembly,sse,avx

AVX is disabled because the entire AMD Bulldozer family does not handle 256-bit AVX instructions efficiently. Internally, the execution units are only 128-bit wide. So 256-bit operations are split up thereby providing no benefit over 128-bit. To add insult to injury, on Piledriver, there's a bug in the 256-bit store...

using ‘-Wcast-qual’ option to check the compilation

c,gcc

Per the comments, it turns out that the OP is using a mac, where gcc as a command is a wrapper around clang - the llvm based compiler. The version of clang that's being used accepts the option but does nothing with it. Support for the warning is being added...

Constructing priority_queue instance with Compare instance of different type

c++,gcc,constructor,containers

The below statement: priority_queue<int, deque<int>, less<int>> pq(greater<int>()); is actually parsed by the compiler as a declaration of pq function that returns an instance of priority_queue, and which takes a single parameter, being a pointer to a function that takes no arguments, and returns an instance of greater<int> type. This is...

When can/will a function be inlined in C++? Can inline behavior be forced?

c++,gcc,clang,compiler-optimization

As a rule, your code is always inlined only if you specify: __attribute__((always_inline)) eg (from gcc documentation): inline void foo (const char) __attribute__((always_inline)); Though it is almost never a good idea to force your compiler to inline your code. You may set a high optimization level (though the O flag)...

different clang and gcc behavior with pointers

c++,c,gcc,clang

pointer_to_check to check is uninitialized. It points to some "random" location. Accessing uninitialized variables leads to Undefined Behavior which means that anything can happen. Also, pointers should be printed using the %p format specifier. with gcc code, we will get zero at output Anything can be the output. It is...

Getting “format not a string literal and no format arguments” warning while using GTK+2

c,security,gcc,gtk,gcc-warning

The answer is quite simple. You have to add "%s" to the arguments of the gtk_message_dialog_new() function like this: static void show_message (gchar *message, GtkMessageType type) { GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, type, GTK_BUTTONS_OK, "%s", message); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } Basically, the lack of "%s" is considered non-secure by gcc. You...

Make c++ macro2 containt quoted body of macro1

c++,gcc,c-preprocessor,qmake

When a C preprocessor macro is expanded, its parameters are expanded to their literal arguments, so s would be expanded to A when your QUOTE(s) taking argument A is expanded. Normally, after this expansion is complete, the expanded text is then scanned again to expand any macros embedded therein, so...

Why size of an empty array is 0 but size of an empty class is not 0?

c++,gcc,g++

This is a C++ only issue. In C, an empty struct is prohibited by the compiler. In C++, the reason for the sizeof(foo) == 1 is ultimately so that the C++ Standard's rule of "no object shall have the same address in memory as any other variable" can be enforced....

C++ GCC/MinGW Paths: ssp, ext, tr1; parallel, ext, bits, experimental

c++,gcc,clang,mingw-w64,libc++

(moving/expanding from the comments) I've always seen stuff being included explicitly from those locations, e.g. <bits/c++config.h>, <ext/bitmap_allocator.h>, <tr1/cmath> and the like, never adding one of those directories directly to the include search path. Notice that, as far as I always understood, the bits directory should be mostly left alone, as...

How to mark function argument as output

c++,c,gcc,attributes,out

"Is it possible to do something similar in C/C++?" Not really. Standard c++ or c doesn't support such thing like a output only parameter. In c++ you can use a reference parameter to get in/out semantics: void func(int& i) { // ^ i = 44; } For c you...

Can I use STDIN for IPC?

c,gcc,ipc,stdin

You can use pipe for IPC. Now if you want to use STDIN_FILENO and STDOUT_FILENO it would look like this: #include <unistd.h> #include <stdio.h> int main(void) { char val = '!'; int filedes[2]; pipe(filedes); int proc = fork(); if (proc < 0) return -1; if (proc == 0) { close(1);...

How to check which symbols on my shared library have non-position independent code (PIC)?

linux,gcc,debian,powerpc

To find which symbols made your elf non-PIC/PIE (Position Independent Code/Executable), use scanelf from pax-utils package (on ubuntu, install it with sudo apt-get install pax-utils): $ scanelf -qT /usr/local/lib/libluajit-5.1.so.2.1.0 | head -n 3 libluajit-5.1.so.2.1.0: buf_grow [0x7694] in (optimized out: previous lj_BC_MODVN) [0x7600] libluajit-5.1.so.2.1.0: buf_grow [0x769C] in (optimized out: previous lj_BC_MODVN)...

Range of immediate values in ARMv8 A64 assembly

gcc,assembly,arm64

Unlike A32's "flexible second operand", there is no common immediate format in A64. For immediate-operand data-processing instructions (ignoring the boring and straightforward ones like shifts), Arithmetic instructions (add{s}, sub{s}, cmp, cmn) take a 12-bit unsigned immediate with an optional 12-bit left shift. Move instructions (movz, movn, movk) take a 16-bit...

Django MySQLClient pip compile failure on Linux

python,linux,django,gcc,pip

It looks like you're missing zlib; you'll want to install it: apt-get install zlib1g-dev I also suggest reading over the README and confirming you have all other dependencies met: https://github.com/dccmx/mysqldb/blob/master/README Also, I suggest using mysqlclient over MySQLdb as its a fork of MySQLdb and what Django recommends....

scanf issue when reading double

c,gcc,double,user-input,scanf

In your code, change scanf("%lf \n", &radius); to scanf("%lf", &radius); Otherwise, with a format string having whitespace, scanf() will behave as below (quoted from C11, chapter §7.21.6.2, paragraph 5) A directive composed of white-space character(s) is executed by reading input up to the first non-white-space character (which remains unread), or...

ARM assembly cannot use immediate values and ADDS/ADCS together

gcc,assembly,arm,instructions

Somewhat ironically, by using UAL syntax to solve the first problem you've now hit pretty much the same thing, but the other way round and with a rather more cryptic symptom. The only Thumb encodings for (non-flag-setting) mov with an immediate operand are 32-bit ones, however Cortex-M0 doesn't support those,...

(solaris) ld: fatal: … version 'GCC_4.2.0' does not exist

c++,gcc,linker

Wow. I feel very silly. All I needed to do was specify the particular version of g++ to use by changing my command to /usr/sfw/bin/g++ testing.cpp Ta-da! Program compiles and runs successfully. In case anyone else has this problem, it might help to run which g++ and try the various...

Checking all elements of array for a logical condition in fortran

gcc,fortran,gfortran

Error: Incompatible ranks 0 and 1 in assignment means that you are trying to assign a rank-1 array to a scalar variable. In this case lg is your scalar left-hand side. As you want to test the condition against each row (as supported by using the [dim=]1 specifier) it makes...

Scoping rules for struct variables in GCC

c,gcc,struct,clang,scoping

As others mentioned, you're reading an uninitialized local variable and that's undefined. So, anything is legit. Having said that, there is a particular reason for this behavior: gcc reuses variables on the stack as much as it can (i.e., as long as the generated code is provably correct). You can...

Print addresses of all local variables in C

debugging,pointers,gcc,gdb,memory-address

There is no built-in command to do this. There is an open feature request in gdb bugzilla to have a way to show the meaning of all the known slots in the current stack frame, but nobody has ever implemented this. This can be done with a bit of gdb...

gcc auto dependency full path

c++,gcc,makefile,g++

The issue is with -I. When gcc is determining the include for <bar.h>, it will find it as ./bar.h, and so it will get printed in the dependency file in that same way. If I were to provide the full path via -I as well: $ g++ -std=c++11 -I/home/barry/sandbox -MP...

Why Unicode characters are not displayed properly in terminal with GCC?

c,gcc,unicode

wprintf is a version of printf which takes a wide string as its format string, but otherwise behaves just the same: %c is still treated as char, not wchar_t. So instead you need to use %lc to format a wide character. And since your strings are ASCII you may as...

How to check the values of a struct from an image/binary file?

c,gcc,binaryfiles

objdump parses object files (products of the compiler), which are relocatable (not executable) ELF files. At this stage, there is no such notion as the memory address these compiled pieces will run at. You have the following possibilities: Link your *.obj files into the final non-stripped (-g passed to compiler)...

Why it is allowed to initialize static variable with non const here?

c,gcc,initialization,const,static-variables

It's because the ideone likely invokes gcc with -O option (optimization level 1). This is the case even for older versions of gcc (mine is 4.4.7): $ gcc -ansi main.c main.c: In function ‘main’: main.c:6: error: initializer element is not constant $ gcc -ansi -O main.c $ echo $? 0...

Makefile with two targets and two languages

c++,c,gcc,makefile

If you must use make, this could help get you started (just for C files): # CLIENT CLIENT_BIN_DIR = client/bin/ CLIENT_SRC_C_DIR = client/src/c/ # CLIENT CLIENT_BIN = $(CLIENT_BIN_DIR)client_app CLIENT_SRC_C = $(wildcard $(CLIENT_SRC_C_DIR)*.c) CLIENT_SRC_C_O = $(CLIENT_SRC_C:.c=.o) CLIENT_SRC_C_D = $(CLIENT_SRC_C:.c=.d) # Flags CFLAGS = -g -W -Wall IFLAGS = -I$(INC_DIR) # Compilers...

How to uglify or minify C code [closed]

c,gcc,minify

sed -rb 's/ {6}//g' main.c | sed -rb 's/\/\/.*$//g' | tr -d '\n' | sed -rb 's/\/\*.*\*\///g' | sed -rb 's/(#include.*>)/\1\n/g' will give you: #include <stdio.h> main(){int i=0;for(i=1; i<=5; i++){printf("Hello %d \n",i);}} However, as stated in the in the comments, this doesn't make much sense and will not reduce the...

How -s option works actually in gcc compilers?

gcc,g++,command-line-interface

On Linux systems, gcc -s probably invokes the strip(1) utility (which remove most symbols from ELF files) from binutils. You could check by running gcc -v -s. To lower the executable size, you should also compile with -Os (in addition of -s) which asks the compiler to optimize for size....

Converting old C code

c,gcc,porting

The idea seems to be to allocate a certain amount of memory (s) and an additional amount to store this size allocated in the same area as a leading block and then return a pointer to just behind the stored size. So try this: void func(void ** p, size_t s)...

Tell C++ that pointer data is 16 byte aligned

c++,gcc,sse,memory-alignment

The compiler isn't vectorizing the loop because it can't determine that the dynamically allocated pointers don't alias each other. A simple way to allow your sample code to be vectorized is to pass the --param vect-max-version-for-alias-checks=1000 option. This will allow the compiler to emit all the checks necessary to see...

Native Code: cannot use typeid with -fno-rtti

c++,osx,gcc,android-ndk,vtk

To enable C++ in the NDK, add LOCAL_CPP_FEATURES := rtti exceptions and LOCAL_CPPFLAGS += --std=c++11 to the jni/Android.mk file. By default, the NDK supports only a C++-like language. Note that there's no underscore between CPP and FLAGS. Also, I've used += because this won't overwrite other flags such as -Wall....

gcc make dependency and object simultaneously

gcc,makefile,g++

I don't know why -M -MF foo.D isn't working for you my reading of the documentation is the same as yours. I think it should be working. An strace of the compilation might tell you something interesting about what is going on. But as a solution you can just add...

minigw-w64 is incapable of 32 byte stack alignment, easy work around or switch compilers?

c++,windows,gcc,alignment,sse

You can solve this problem by switching to Microsoft's 64-bit C/C++ compiler. The problem is not intrinsic to 64-bit Windows. Despite what Kai Tietz said in the bug report you linked, Microsoft's x64 ABI does allow a compiler to give variables a greater than 16-byte alignment on the stack. Also...

Error by Compiler gcc: undefined reference to `main'

c,linux,algorithm,sorting,gcc

It would be more readable if you kept the code formatting for the whole code, not just its part. But when I tried to find a main function, I didn't find any. Therefore there is no reference to main because you haven't implemented one, at least not in the code...

Does gcc search CPATH recursively?

gcc,include

CPATH specifies the list of directories to search. The compiler searches exactly those directories, not any sub-directories (so no recursive searching). That is, given a name from #include "somedir/header.h", it will look in the directories specified via -I and -isystem and specified via CPATH and will add /somedir/header.h to each...

[ performance]— string::operator+= vs. vector push_back

c++,string,gcc,vector,char

Strings and vectors both store their content contiguously. If there's not enough room for adding a new element, the capacity must be increased (memory allocation) and the existing content must be moved to the new location. Hence, the performance should depend significantly on the allocation strategy of your implementation. If...

fatal error: limits.h: No such file or directory

xcode,osx,gcc

Make sure you've installed the xcode command-line tools: xcode-select --install (Accept the pop-up dialog.) That will install system headers into standard locations expected by tools like gcc, e.g. /usr/include....

gcc compilation with linker - differences

c,gcc,linker

-lm will link in libm. By default gcc will search for the shared library first. If the shared version is not found it will then search for the static version. The trailing -Wl,-Bdynamic is to ensure that the shared version of standard libraries (ie, libc) are used. -static prevents...

How to set compiler-specific flags with autotools

gcc,clang,autotools,compiler-options

AM_CXXFLAGS isn't something you should AC_SUBST. It is reserved for use by automake. If you look at the Makefile generated for a C++ target, you will find definitions for CXXCOMPILE and LTCXXCOMPILE, which always include the AM_CXXFLAGS variable. You want to add the (conditional) compiler flag to AM_CXXFLAGS or to...