* Makefile.in: Major changes. Removed some the sed
[deliverable/binutils-gdb.git] / ld / PORTING
CommitLineData
7e5c1057
PB
1Some incomplete notes about porting GNU ld
2-----------------------------------------
3
4Before porting ld itself, you will need to port the BFD library.
5
6We tarlk about the 'host' system as the machine and software
7nevironment where ld runs (generates an execuitble *on*),
8while the 'target' is the machine ld generates an executable *for*.
9Most often, host==target, but ld supports cross-linking
10(and to some extent the same ld binary can be used a linker
11for multiple target rachitectures).
12
13Doing a 'host' port means working around broken or missing
14include files or libraries. ...
15
16Porting to a new target
17-----------------------
18
19Writing a new script script
20---------------------------
21
22You may need to write a new script file for your emulation.
23
24The variable RELOCATING is only set if relocation is happening
25(i.e. unless the linker is invoked with -r).
26Thus your script should has an action ACTION
27that should only be done when relocating,
28express that as:
29 ${RELOCATING+ ACTION}
30In general, this is the case for most assignments, which should look like:
31 ${RELOCATING+ _end = .}
32
33Also, you should assign absolute addresses to sections only
34when relocating, so:
35 .text ${RELOCATING+ ${TEXT_START_ADDR}}:
36
37The forms:
38 .section { ... } > section
39should be:
40 .section { ... } > ${RELOCATING+ section}
41
42Old Makefile comments (re-write - FXIME!)
43-----------------------------------------
44
45# The .xn script is used if the -n flag is given (write-protect text)..
46# Sunos starts the text segment for demand-paged binaries at 0x2020
47# and other binaries at 0x2000, since the exec header is paged in
48# with the text. Some other Unix variants do the same.
49# For -n and -N flags the offset of the exec header must be removed.
50# This sed script does this if the master script contains
51# a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the
52# output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.)
53.x.xn:
54 sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
55
56# The .xN script is used if the -N flag is given (don't write-protect text).
57# This is like -n, except that the data segment need not be page-aligned.
58# So get rid of commands for page-alignment: We assume these use ALIGN
59# with a hex constant that end with 00, since any normal page size is be
60# at least divisible by 256. We use the 00 to avoid matching
61# anything that tries to align of (say) 8-byte boundaries.
62.xn.xN:
63 sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
This page took 0.025273 seconds and 4 git commands to generate.