20
Compiling, Linking, and Locating

Compiling, Linking, And Locating

  • Upload
    aravind

  • View
    237

  • Download
    0

Embed Size (px)

Citation preview

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 1/20

Compiling, Linking, and

Locating

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 2/20

 The frst program

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 3/20

BUILD PROCESS IN EMBEDDEDSYSTEM

•  The process which converts source code toexecutable code is called as the build process.

•  The build process or embedded systems is

dierent. This is because the code to be run onan embedded system is written one platormi.e. general purpose computer and executed onanother platorm i.e. the target hardware.

 The build process involves three steps – Compiling

 – Linking

 – Locating

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 4/20

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 5/20

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 6/20

Compiler

•  The compiler takes input as sourcecode fles and gives output as multipleob!ect fles.

• "x. Turbo C## is a native compiler. Thecompiler in case o embedded systemsdevelopment is a cross compiler $while

compiling the programmer has to selectthe target processor or which the codehas to be generated%

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 7/20

Compiler

• & compiler which produces theexecutable code to be run on adierent platorm is called a cross'

compiler( else it is called a nativecompiler.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 8/20

Linking

•  The output o compiler is multiple ob!ect fles. These fles areincomplete in the sense that they may contain reerence tovariables and unctions across multiple ob!ect fles which needto be resolved.

•  The !ob o the linker is to combine these multiple ob!ect flesand resolve the unresolved symbols.

•  The linker takes input as multiple ob!ect fles and gives outputas a single ob!ect fle which is also called as the relocatablecode.

•  The Linker does this by merging the various sections like text,data, and bss o the individual ob!ect fles.

•  The output o the linker will be a single fle which contains allo the machine language code rom all o the input ob!ectfles.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 9/20

Locating

•  The process o relocating is carried out by the relocater.

•  The relocater takes input as the relocatable code producedby the linker and gives output as the fnal executable code.

•  This output is a binary executable fle which is called )ex'

Code.•   The locator needs to be given inormation about the

memory available on the target processor.

•  The locator will use this inormation to assign physicalmemory addresses to each o the code and data sections

within the relocatable program code.• *inally it produces an output fle that contains a binary

memory image that can be loaded into the targetprocessors +-.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 10/20

 Tool Chain

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 11/20

DOWNLOADING THE EMBEDDEDCODE

•  The code to be run on the target embeddedsystem is always developed on the hostcomputer. This code is called the binary

executable image or simply hex code.•  The process o putting this code in the

memory chip o the target embeddedsystem is called ownloading

•  There are two ways o downloading thebinary image on the embedded system /, 01/

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 12/20

Device Prograer

& device programmer is a piece o hardware that works intwo steps.

Ste! "nce the binary image is ready on the computer, the device

programmer is connected to the computer and the binary image istranserred to the device programmer.

Ste! # The microcontroller2microprocessor or memory chip, usually the +-which is supposed to contain the binary image is placed on the proper

socket on the device programmer. The device programmer contains asotware interace through which the user selects the targetmicroprocessor or which the binary image has to be downloaded. The evice programmer then transers the binary image bit by bit tothe chip.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 13/20

In S$%te Prograer&ISP'

• )ardware interace to both thecomputer as well the chip where the code isto be downloaded.

 The user through the 01/3s sotware interacesends the binary image to the target board.

•  This avoids the re4uirement o re4uentlyremoving the microprocessor 2

microcontroller or +- or downloading thecode i a device programmer had to be used.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 14/20

DEBUGGING THE EMBEDDEDSO(TWARE

• ebugging is the process o eliminating the bugs2errorsin sotware.

•  The sotware written to run on embedded systems maycontain errors and hence needs debugging.

• )owever, the di5culty in case o embedded systems isto fnd out the bug2 error itsel. This is because thebinary image you downloaded on the target board wasree o syntax errors but still i the embedded systemdoes not unction the way it was supposed to be then it

can be either because o a hardware problem or asotware problem. &ssuming that the hardware isperect all that remains to check is the sotware.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 15/20

•  The di5cult part here is that once the embeddedsystem starts unctioning there is no way or theuser or programmer to know the internal state othe components on the target board.

•  The most primitive method o debugging is usingL"s. This is similar to using a print or a coutstatement in c2c## programs to test i the controlenters the loop or not. 1imilarly an L" blink or a

pattern o L" blinks can be used to check i thecontrol enters a particular piece o code.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 16/20

•  There are other advanced debuggingtools like( – +emote debugger

 – "mulator

 – 1imulator

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 17/20

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 18/20

"mulator

• & +emote debugger is helpul or monitoring and controllingthe state o embedded sotware prior to downloading it only.

• &n "mulator allows you to examine the state o the processoron which that program is actually running. 0t is itsel anembedded system, with its own copy o the target processor,

+&-, +-, and its own embedded sotware

• &n "mulator takes the place o'or emulates'the processor onthe target board.

• "mulator uses a remote debugger or its human interace.

• In)circ*it emulation $0C"% is the use o a hardware device or

in)circ*it e*+ator used to debug the sotware o anembedded system. 0t operates by using a processor with theadditional ability to support debugging operations, as well asto carry out the main unction o the system.

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 19/20

7/25/2019 Compiling, Linking, And Locating

http://slidepdf.com/reader/full/compiling-linking-and-locating 20/20

ther Tools

• Logic Ana+$,er%

  To convert the captured data into timingdiagrams, protocol decodes, state machine

traces, assembly language, or may correlateassembly with source'level sotware

• O%ci++o%co!e%

  Electronic test instrument that allows

observation o constantly varying signalvoltages, usually as a two'dimensional ploto one or more signals as a unction o time.