Altera_Forum
Honored Contributor
14 years agoDifferences between dcc/objdump and nios2-elf-gcc/nios2-elf-objdump?
Hi!
I'm trying to get some information out of the elf-file but it seems that there are some differences between the regular tools and the tools with nios2-elf- prefix. Before I start to explain my problem - Here's the (nonsense-) code I am compiling with both gcc editions: test.c#include "testb.h"
int myGlobalVar = 2;
volatile int myVolatileVar = 4;
myStruct globalStruct = {2, 3, 4};
int main() {
int bla = funca(13, 44);
double yeah = funcb();
bla += 2;
return bla;
} testb.h int funca(int myParam1, int myParam2) {
int jack = (myParam1 + 32) - myParam2;
jack += (64 + myParam2);
return jack;
}
typedef struct myStruct {
int lorem;
double ipsum;
char dolor;
} myStruct;
double funcb() {
long xmas = 8;
float easter = (float)xmas + 8.1f;
return (double)xmas;
} If I compile the code with the regular gcc using $ gcc -g ./test.c -otest.exe and create an object dump using $ objdump -g ./test.exe > objdump.txt I get this: ./test.exe: file format pei-i386
/cygdrive/c/Documents and Settings/xyz/Desktop/./test.c:
typedef int32 int;
typedef int8 char;
typedef int32 long int;
typedef uint32 unsigned int;
typedef uint32 long unsigned int;
typedef int64 long long int;
typedef uint64 long long unsigned int;
typedef int16 short int;
typedef uint16 short unsigned int;
typedef int8 signed char;
typedef uint8 unsigned char;
typedef float float;
typedef double double;
typedef float96 long double;
typedef struct %anon1 { /* size 8 */
int real; /* bitsize 32, bitpos 0 */
int imag; /* bitsize 32, bitpos 32 */
} complex int;
typedef complex float0 complex float;
typedef complex float0 complex double;
typedef complex float0 complex long double;
typedef void void;
typedef char *__builtin_va_list;
typedef bool32 boolean;
typedef boolean _Bool;
/* file ./testb.h line 2 addr 0x401050 */
/* file ./testb.h line 3 addr 0x401056 */
/* file ./testb.h line 4 addr 0x401064 */
/* file ./testb.h line 6 addr 0x401070 */
/* file ./testb.h line 7 addr 0x401073 */
/* file ./testb.h line 15 addr 0x401075 */
/* file ./testb.h line 16 addr 0x40107b */
/* file ./testb.h line 17 addr 0x401082 */
/* file ./testb.h line 18 addr 0x401090 */
/* file ./testb.h line 19 addr 0x401093 */
int main ()
{ /* 0x401095 */
{ /* 0x401095 */
double yeah /* 0xfffffff0 */;
int bla /* 0xfffffffc */;
/* file ./test.c line 8 addr 0x401095 */
/* file ./test.c line 8 addr 0x4010ba */
/* file ./test.c line 9 addr 0x4010bf */
/* file ./test.c line 10 addr 0x4010d6 */
/* file ./test.c line 11 addr 0x4010de */
/* file ./test.c line 12 addr 0x4010e4 */
/* file ./test.c line 13 addr 0x4010e7 */
} /* 0x4010e9 */
} /* 0x4010e9 */
./testb.h:
int funca (int myParam1 /* 0x8 */, int myParam2 /* 0xc */)
{ /* 0x401050 */
{ /* 0x401050 */
int jack /* 0xfffffffc */;
} /* 0x401075 */
} /* 0x401075 */
struct myStruct { /* size 24 id 2 */
int lorem; /* bitsize 32, bitpos 0 */
double ipsum; /* bitsize 64, bitpos 64 */
char dolor; /* bitsize 8, bitpos 128 */
};
typedef struct myStruct /* id 2 */ myStruct;
double funcb ()
{ /* 0x401075 */
{ /* 0x401075 */
float easter /* 0xfffffff8 */;
long int xmas /* 0xfffffffc */;
} /* 0x401095 */
} /* 0x401095 */
./test.c:
int myGlobalVar /* 0x402000 */;
int volatile myVolatileVar /* 0x402004 */;
myStruct globalStruct /* 0x402008 */; But if I compile the code with the regular gcc using $ nios2-elf-gcc -g ./test.c -otest.exe and create an object dump using $ nios2-elf-objdump -g ./test.exe > objdump.txt I get this: ./test.exe: file format elf32-littlenios2 Why is there no information about the variables, structs and so on?