gcc

C Function alignment in GCC

I am trying to byte-align a function to 16-byte boundary using the 'aligned(16)' attribute. I did the following: void __attribute__((aligned(16))) function() { } (Source: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html) But when I compile (gcc foo.c ; no makefiles or linker scripts used), I get the following error: FOO...

Help with Assembly. Segmentation fault when compiling samples on Mac OS X.

Hi, I'm trying to learn assembly using Dr Paul Carter's pcasm book: http://www.drpaulcarter.com/pcasm/ The author doesn't packaged Mac OS X samples, then I've started using from linux sources. Here is the first sample, that uses his library asm_io. I'm getting Segmentation Fault when running it. Why? What need to be changed to run in ...

Threads or Processes? Having data-independent tasks, what is better to use?

There is a set of N real-time data-independent tasks. Each of the tasks processes some digital data stream. A data stream for each task comes from an input port and a resulted stream then is being directed to an output port. 1) What is computationally less intensive: tasks in form of the processes or threads? 2) Does best choice depen...

"Undefined Reference" Error From ld

Hi there! This isn't as naive as the title may lead you to think. I receive an "Undefined Reference" Error from the linker/ld for a couple of function symbols in third party shared library, that I'm trying to link with my executable. The strange part is, that library itself is supposed to contain the definition for the offending symb...

How do you detect the CPU architecture type during run-time with GCC and inline asm?

Hello, I need to find the architecture type of a CPU. I do not have access to /proc/cpuinfo, as the machine is running syslinux. I know there is a way to do it with inline ASM, however I believe my syntax is incorrect as my variable iedx is not being set properly. I'm drudging along with ASM, and by no means an expert. If anyone has an...

Carbide does not include debugging info for some files

In Carbide 2.0.2, if I set active configuration to be "Phone Debug GCCE", build the project, go to Debug perspective, choose "Executables" tab, and select the executable file, Source File Name/Location window will list all the files I am able to use while debugging. The problem is that the list does not contain all files from the projec...

Writing software for E-Book Reader Devices

Can you please recommend any E-Book Reader which can execute a third-party software, so that anybody can create software for such device? ...

How to resolve shared library linking during compilation( GCC ) ?

I have built libshared.so with is dependent on libshared_dependent.so Now, I am compiling app.bin which is using libshared.so, Now at compile time gcc wants me to specify -lshared_dependent other wise it gives error that some symbols not found. Is there any way by which, At compile time I don't need to specify -lshared_dependent, I wan...

x86: howto catch data-alignment faults (aka SIGBUS on sparc)

Is it somehow possible to catch data-alignment faults even on i386? Maybe by setting a i386 specific machine register or something like that. On Solaris-Sparc I am receiving a SIGBUS in this case, but on i386 everything is fine. Environment: 32-bit application Ubuntu Karmic gcc/g++ v4.4.1 EDIT: Here is why I am asking this: our ...

AT&T inline syntax

can anyone show my the correct AT&T syntax to do what i'm doing below in INTEL i've shown my attempts at AT&T, but they don't compile... unsigned int CheckIfGenuineIntel(void) { unsigned int VendorIdentificationString[4] = {0, 0, 0, 0}; #if defined( _DO_INTEL_ ) __asm__ __volatile__ ( "xor eax, eax\n\t" "cpu...

Accessing main program global variables from a dlopen()ed dynamic library in C on OS X

I am maintaining a small application that has some plugin-like functionality, which is implemented through runtime-loaded dynamic modules. Specifically, since it's a Gtk+ app, I'm using gmodule, but the question applies to dlfcn.h / dlopen() based dynamic library loading just as well. My main program has a single, global struct variab...

How can I check that I didn't break anything when refactoring?

I'm about to embark on a bout of refactoring of some functions in my code. I have a nice amount of unit tests that will ensure I didn't break anything, but I'm not sure about the coverage they give me. Are there any tools that can analyze the code and see that the functionality remains the same? I plan to refactor some rather isolated...

What are the gcc preprocessor flags for the compiler's version number?

I have run into a bug with gcc v3.4.4 and which to put an #ifdef in my code to work around the bug for only that version of the compiler. What are the GCC compiler preprocessor flags to detect the version number of the compiler? Thanks. ...

GCC outputs error "undefined reference to `printf'" when using an NASM extern statement to access printf.

I am learning NASM and am tying to compile this code (which I found here). It assembles using this NASM command: nasm -f coff -l printf.lst printf1.asm to printf.o but this gcc linking command: gcc -o printf1 printf1.o fails with the error: printf1.o:printf1.asm:(.text+0x1a): undefined reference to `printf' collect2: ld returned...

Segmentation fault when executing program compiled from x86 assembly?

Hi everybody! I'm new to assembly language and I have to implement a function, in my case sin(x), that could be called from a C source file. I have to make 2 separate files: *.c and *.s When compiling through gcc on ubuntu all good, but when the program executes it gives me the error "Segmentation fault"... To compile I type: gcc -c -o...

Help needed with F_NOCACHE in mac

Hello Everybody, I am Srinivasa Raghavan and new to this group. I am facing problem with non caching the file. the code looks like the below: main() { int fd; char buf[512] = {'\0'}; fd = fopen("Sample.bin",O_RDONLY); fcntl(fd, F_NOCACHE, 1); fcntl(fd, F_RDAHEAD, 1); read(fd, buf, sizeof(buf)); close(fd);...

Trying to compile code from OS Dev tutorial

This is a hard question to ask because I'm positive I'm about to be bombarded with haters commenting on "if I can't write an operating system already, I won't ever to be able to write an operating system". Well I've read Modern OS by Tanembaum, Linux Kernel Development, Understanding the Linux kernel and others I still don't know if or n...

invalid static assert behavior

I am trying to setup a static assert (outside the main function) with GCC v4.3.x: #define STATIC_ASSERT(cond) extern void static_assert(int arg[(cond) ? 1 : -1]) STATIC_ASSERT( (double)1 == (double)1 ); // failed but when I use float numbers, the assert always failed. Is it possible to run this static assert properly ? ...

When including header files, is the path case sensitive?

Given this directory tree: src/MyLibrary/MyHeader.h src/file.cpp file.cpp: #include "mylibrary/myheader.h" ... Compiling file.cpp works with VS, fails in gcc. What does the standard say? If the path is case sensitive, why is this wise? What's the best practice, keep all file/folder names lowercase and thus do the same when includi...

GLIBCXX_3.4.9 not found

Hi, I have a problem concerning libstdc++.so. I installed a new version of gcc and tried to compile c++ code. The compiling worked, but when I try to execute the binary (m5.opt is its name) I've got the following error: build/ALPHA_SE/m5.opt: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by build/ALPHA_SE/m5.op...