source: mainline/boot/arch/ppc32/loader/pack@ 94d614e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 94d614e was fb0e6f03, checked in by jermar <jermar@…>, 17 years ago

Merge the boot branch.

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#! /bin/sh
2
3#
4# Copyright (C) 2006 Martin Decky
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# - Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# - Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution.
16# - The name of the author may not be used to endorse or promote products
17# derived from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29#
30
31[ "$#" -lt 1 ] && exit 1
32
33OBJCOPY="$1"
34LINK="_link.ld"
35HEADER="_components.h"
36
37shift
38
39echo 'OUTPUT_FORMAT("elf32-powerpc")
40OUTPUT_ARCH(powerpc:common)
41ENTRY(start)
42
43SECTIONS {
44 .boot 0x10000000: AT (0) {
45 *(BOOTSTRAP);
46 *(REALMODE);
47 *(.text);
48
49 *(.rodata);
50 *(.rodata.*);
51 *(.data); /* initialized data */
52 *(.sdata);
53 *(.sdata2);
54 *(.sbss);
55 *(.bss); /* uninitialized static variables */
56 *(COMMON); /* global variables */' > "$LINK"
57
58echo '#ifndef ___COMPONENTS_H__
59#define ___COMPONENTS_H__
60
61typedef struct {
62 char *name;
63
64 void *start;
65 void *end;
66 unsigned int size;
67} component_t;' > "$HEADER"
68
69COUNT="0"
70DATA=""
71
72for TASK in "$@" ; do
73 BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`"
74 OBJECT="${BASENAME}.o"
75 SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`"
76 MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`"
77 echo "$TASK -> $OBJECT"
78
79 echo "
80 . = ALIGN(4096);
81 *(.${BASENAME}_image);" >> "$LINK"
82
83 echo "
84extern int ${SYMBOL}_start;
85extern int ${SYMBOL}_end;
86
87#define ${MACRO}_START ((void *) &${SYMBOL}_start)
88#define ${MACRO}_END ((void *) &${SYMBOL}_end)
89#define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER"
90
91 "$OBJCOPY" -I binary -O elf32-powerpc -B powerpc:common --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT"
92
93 DATA="${DATA}
94 components[$COUNT].name = \"${BASENAME}\";
95 components[$COUNT].start = ${MACRO}_START;
96 components[$COUNT].end = ${MACRO}_END;
97 components[$COUNT].size = ${MACRO}_SIZE;";
98 COUNT="`expr "$COUNT" + 1`"
99done
100
101echo ' }
102}' >> "$LINK"
103
104echo "
105#define COMPONENTS $COUNT
106
107component_t components[COMPONENTS];
108
109static void init_components(void)
110{
111$DATA
112}
113
114#endif
115" >> "$HEADER"
Note: See TracBrowser for help on using the repository browser.