User Tools

Site Tools


programming

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programming [2009/06/19 03:42] memeruizprogramming [2021/02/01 05:55] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Programming ====== ====== Programming ======
 +
 +[[bash]]
 +
 ===== C ===== ===== C =====
   * With GCC one can do inline functions (useful with microcontrollers). [[http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Inline.html#Inline]] . Useful gcc command line: -Winline   * With GCC one can do inline functions (useful with microcontrollers). [[http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Inline.html#Inline]] . Useful gcc command line: -Winline
Line 115: Line 118:
   * Canceling implicit rules.      %.o : %.s   * Canceling implicit rules.      %.o : %.s
   * study the following commands. Seem to be useful: cat cmp cp diff echo egrep expr false grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true   * study the following commands. Seem to be useful: cat cmp cp diff echo egrep expr false grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
 +  * Quick reference [[http://www.gnu.org/software/make/manual/make.html#Quick-Reference|here]]
 +
 +===== Microcontrollers and GCC =====
  
 +Programming and generating code for a system where Linux is already running usually involves just writing the source code for the program, some libraries and some Makefiles. One thing that is always happening, every time that some code is generated that can be useful to use in a system, is linking. During linking basically the code generated by the compiling process, called object code, from all the source files plus the code from library files gets "linked" in one single output object code in a specific format. This linking process is necessary because the operating system needs the information of how and where to look for code from other "shared libraries", also how to put the code generated in memory and also how to execute this code.  Something I didn't know is that this information on how linking should happen is specified in two ways. First with specific standards and object file types and, second with instructions given to the linker using a linker script file.
 +The approach that I follow to deal with this was the following:
 +  - Get an example of a project for a microcontroller that requires to set memory layouts by hand, I got an example for the stm32 Arm microcontrollers.
 +  - Read the complete GCC users manual. This is important to know what is going on during the whole compilation process.
 +  - Read the complete Makefile users manual. This is big but very important. Now I understand much more variations of Makefiles.
 +  - Read the complete manual for ld the linker. This is where you will find the information for writing linker scripts.
  
 +You may wander why you don't have to do this in your linux i386 PC computer, this is because there is already a default ld script for your system and it gets used automatically. So you don't notice. But if you dare you can try to write your own ld script for your i386 and try to get your program running with it.
  
  
programming.1245382950.txt.gz · Last modified: 2021/02/01 05:55 (external edit)