Changeset 960f8476 in mainline


Ignore:
Timestamp:
2008-05-30T14:22:58Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
afb1e35
Parents:
136edca
Message:

finish unifying pack script

Location:
boot
Files:
3 added
2 deleted
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • boot/arch/arm32/loader/Makefile

    r136edca r960f8476  
    3333#
    3434
    35 BFD = elf32-littlearm
    3635BFD_NAME = elf32-littlearm
    3736BFD_ARCH = arm
     
    112111        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
    113112
    114 _components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
    115         ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD) $(BFD_ARCH) 4096 $(COMPONENTS)
     113_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
     114        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 4096 "unsigned int" $(COMPONENTS)
    116115
    117116%.o: %.S
  • boot/arch/arm32/loader/_link.ld.in

    r136edca r960f8476  
     1OUTPUT_FORMAT("elf32-littlearm")
     2ENTRY(start)
     3
     4SECTIONS {
    15        .boot 0x0: AT (0) {
    26                *(BOOTSTRAP);
     
    1620                . = 0x4000;
    1721                *(PT);                  /* page table placed at 0x4000 */
     22[[COMPONENTS]]
     23        }
     24}
  • boot/arch/ia64/loader/Makefile

    r136edca r960f8476  
    3333#
    3434
     35BFD_NAME = elf64-ia64-little
     36BFD_ARCH = ia64
    3537TARGET = ia64-pc-linux-gnu
    3638TOOLCHAIN_DIR = /usr/local/ia64/bin
     
    7880        ../../../generic/string.c \
    7981        ../../../genarch/balloc.c \
     82        _components.c \
    8083        asm.S \
    8184        boot.S
     
    9699        $(USPACEDIR)/app/klog/klog
    97100
    98 
    99101OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
    100102COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
     
    106108-include Makefile.depend
    107109
    108 
    109110hello.efi: image.boot
    110111        make -C gefi/HelenOS PREFIX=$(GEFI_PREFIX)
     
    114115
    115116image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS)
    116         $(LD) -Map boot.map -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
     117        $(LD) -Map image.map -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
    117118
    118119depend:
     
    120121
    121122clean:
    122         -rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot boot.disasm Makefile.depend
     123        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot image.map image.disasm Makefile.depend
    123124        make -C gefi/HelenOS clean
    124125
    125 _components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
    126         ./pack $(IMAGE) $(OBJCOPY) $(COMPONENTS)
     126_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
     127        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 16384 "unsigned long" $(COMPONENTS)
    127128
    128129%.o: %.S
     
    133134
    134135disasm: image.boot
    135         $(OBJDUMP) -d image.boot > boot.disasm
     136        $(OBJDUMP) -d image.boot > image.disasm
  • boot/arch/mips32/loader/Makefile

    r136edca r960f8476  
    3434
    3535ifeq ($(IMAGE),binary)
    36         BFD = binary
     36        LD_IN = binary
    3737endif
    3838ifeq ($(IMAGE),ecoff)
    39         BFD = ecoff-littlemips
     39        LD_IN = ecoff
    4040endif
    4141BFD_NAME = elf32-tradlittlemips
     
    109109
    110110clean:
    111         -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
     111        -rm -f _components.h _components.c _link.ld _link.ld.in $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
    112112
    113 _components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
    114         ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD) $(BFD_ARCH) 4096 $(COMPONENTS)
     113_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
     114        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 4096 "unsigned int" $(COMPONENTS)
     115
     116_link.ld.in: _link.ld.in.$(LD_IN)
     117        cp $< $@
    115118
    116119%.o: %.S
  • boot/arch/mips32/loader/_link.ld.in.binary

    r136edca r960f8476  
     1OUTPUT_FORMAT("binary")
     2ENTRY(start)
     3 
     4SECTIONS {
    15        .boot 0xbfc00000: AT (0) {
    26                *(BOOTSTRAP);
     
    1317                *(COMMON);              /* global variables */
    1418                *(.reginfo);
     19[[COMPONENTS]]
     20        }
     21}
  • boot/arch/ppc32/loader/Makefile

    r136edca r960f8476  
    3333#
    3434
    35 BFD = elf32-powerpc
    3635BFD_NAME = elf32-powerpc
    3736BFD_ARCH = powerpc:common
     
    107106        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
    108107
    109 _components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
    110         ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD) $(BFD_ARCH) 4096 $(COMPONENTS)
     108_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
     109        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 4096 "unsigned int" $(COMPONENTS)
    111110
    112111%.o: %.S
  • boot/arch/ppc32/loader/_link.ld.in

    r136edca r960f8476  
     1OUTPUT_FORMAT("elf32-powerpc")
     2OUTPUT_ARCH(powerpc:common)
     3ENTRY(start)
     4 
     5SECTIONS {
    16        .boot 0x10000000: AT (0) {
    27                *(BOOTSTRAP);
     
    1217                *(.bss);                /* uninitialized static variables */   
    1318                *(COMMON);              /* global variables */
     19[[COMPONENTS]]
     20        }
     21}
  • boot/arch/ppc64/loader/Makefile

    r136edca r960f8476  
    3333#
    3434
    35 BFD = elf64-powerpc
    3635BFD_NAME = elf64-powerpc
    3736BFD_ARCH = powerpc:common64
     
    107106        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
    108107
    109 _components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
    110         ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD) $(BFD_ARCH) 4096 $(COMPONENTS)
     108_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
     109        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 4096 "unsigned long" $(COMPONENTS)
    111110
    112111%.o: %.S
  • boot/arch/ppc64/loader/_link.ld.in

    r136edca r960f8476  
     1OUTPUT_FORMAT("elf64-powerpc")
     2OUTPUT_ARCH(powerpc:common64)
     3ENTRY(start)
     4 
     5SECTIONS {
    16        .boot 0x0000000010000000: AT (0) {
    27                *(BOOTSTRAP);
     
    1419                *(.bss);                /* uninitialized static variables */   
    1520                *(COMMON);              /* global variables */
     21[[COMPONENTS]]
     22        }
     23 
     24    /DISCARD/ : {
     25        *(*);
     26    }
     27}
  • boot/arch/sparc64/loader/Makefile

    r136edca r960f8476  
    3333#
    3434
     35BFD_NAME = elf64-sparc
     36BFD_ARCH = sparc
    3537TARGET = sparc64-linux-gnu
    3638TOOLCHAIN_DIR = /usr/local/sparc64/bin
     
    6466SOURCES = \
    6567        main.c \
     68        _components.c \
    6669        ../../../generic/printf.c \
    6770        ../../../generic/string.c \
     
    104107
    105108clean:
    106         -rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot boot.disasm Makefile.depend
     109        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot image.map image.disasm Makefile.depend
    107110
    108 _components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
    109         ./pack $(IMAGE) $(OBJCOPY) $(COMPONENTS)
     111_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS) _link.ld.in
     112        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 1 "unsigned long" $(COMPONENTS)
    110113
    111114%.o: %.S
     
    116119
    117120disasm: image.boot
    118         $(OBJDUMP) -d image.boot > boot.disasm
     121        $(OBJDUMP) -d image.boot > image.disasm
  • boot/tools/pack.py

    r136edca r960f8476  
    3737def usage(prname):
    3838        "Print usage syntax"
    39         print prname + " <OBJCOPY> <FORMAT> <OUTPUT_FORMAT> <ARCH> <ALIGNMENT>"
     39        print prname + " <OBJCOPY> <FORMAT> <ARCH> <ALIGNMENT> <UINTPTR>"
    4040
    4141def main():
     
    4444                return
    4545       
    46         if (not sys.argv[5].isdigit()):
     46        if (not sys.argv[4].isdigit()):
    4747                print "<ALIGNMENT> must be a number"
    4848                return
    4949       
    50         templatename = "_link.ld.in"
    51         workdir = os.getcwd()
    5250        objcopy = sys.argv[1]
    5351        format = sys.argv[2]
    54         output_format = sys.argv[3]
    55         arch = sys.argv[4]
    56         align = int(sys.argv[5], 0)
     52        arch = sys.argv[3]
     53        align = int(sys.argv[4], 0)
     54        uintptr = sys.argv[5]
    5755       
    58         link = file("_link.ld", "w")
     56        workdir = os.getcwd()
     57       
    5958        header = file("_components.h", "w")
    6059        data = file("_components.c", "w")
    61        
    62         link.write("OUTPUT_FORMAT(\"" + output_format + "\")\n")
    63         link.write("OUTPUT_ARCH(" + arch + ")\n")
    64         link.write("ENTRY(start)\n\n")
    65         link.write("SECTIONS {\n")
    66        
    67         size = os.path.getsize(templatename)
    68         rd = 0
    69         template = file(templatename, "r")
    70        
    71         while (rd < size):
    72                 buf = template.read(4096)
    73                 link.write(buf)
    74                 rd += len(buf)
    75        
    76         template.close()
    77        
    78         link.write("\n")
    7960       
    8061        header.write("#ifndef ___COMPONENTS_H__\n")
     
    8667       
    8768        cnt = 0
     69        link = ""
    8870        for task in sys.argv[6:]:
    8971                basename = os.path.basename(task)
     
    9678                print task + " -> " + object
    9779               
    98                 link.write("\t\t. = ALIGN(" + ("%d" % align) + ");\n")
    99                 link.write("\t\t*(." + plainname + "_image);\n\n")
     80                if (align > 1):
     81                        link += "\t\t. = ALIGN(" + ("%d" % align) + ");\n"
     82               
     83                link += "\t\t*(." + plainname + "_image);\n"
    10084               
    10185                header.write("extern int " + symbol + "_start;\n")
     
    10387                header.write("#define " + macro + "_START ((void *) &" + symbol + "_start)\n")
    10488                header.write("#define " + macro + "_END ((void *) &" + symbol + "_end)\n")
    105                 header.write("#define " + macro + "_SIZE ((unsigned int) " + macro + "_END - (unsigned int) " + macro + "_START)\n\n")
     89                header.write("#define " + macro + "_SIZE ((" + uintptr + ") " + macro + "_END - (" + uintptr + ") " + macro + "_START)\n\n")
    10690               
    10791                data.write("\tcomponents[" + ("%d" % cnt) + "].name = \"" + plainname + "\";\n")
     
    119103                os.chdir(workdir)
    120104               
    121                 cnt = cnt + 1
     105                cnt += 1
    122106               
    123         link.write("\t}\n")
    124         link.write("}\n")
    125        
    126107        header.write("#define COMPONENTS " + ("%d" % cnt) + "\n\n")
    127108        header.write("typedef struct {\n")
     
    129110        header.write("\tvoid *start;\n")
    130111        header.write("\tvoid *end;\n")
    131         header.write("\tunsigned int size;\n")
     112        header.write("\t" + uintptr + " size;\n")
    132113        header.write("} component_t;\n\n")
    133114        header.write("extern void init_components(component_t *components);\n\n")
     
    136117        data.write("}\n")
    137118       
    138         link.close()
    139119        header.close()
    140120        data.close()
     121       
     122        linkname = "_link.ld"
     123        link_in = file(linkname + ".in", "r")
     124        template = link_in.read(os.path.getsize(linkname + ".in"))
     125        link_in.close()
     126       
     127        link_out = file(linkname, "w")
     128        link_out.write(template.replace("[[COMPONENTS]]", link))
     129        link_out.close()
    141130
    142131if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.