diff options
author | Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> | 2008-04-16 14:13:45 +0000 |
---|---|---|
committer | Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> | 2008-04-16 14:13:45 +0000 |
commit | 0572a73ab46f3c03cb20f552447ae01cff2fa3df (patch) | |
tree | 5f44d4387f7414494deadea093fe8115462dd8e0 /ldso | |
parent | 59dccdf29609ae6063c769ba07cd53c6ab22071a (diff) |
Fix whitespace damage in AVR32 part of ldso.
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/ldso/avr32/dl-startup.h | 126 | ||||
-rw-r--r-- | ldso/ldso/avr32/dl-sysdep.h | 88 | ||||
-rw-r--r-- | ldso/ldso/avr32/elfinterp.c | 240 | ||||
-rw-r--r-- | ldso/ldso/avr32/resolve.S | 28 |
4 files changed, 241 insertions, 241 deletions
diff --git a/ldso/ldso/avr32/dl-startup.h b/ldso/ldso/avr32/dl-startup.h index 2280b2629..3b9a64176 100644 --- a/ldso/ldso/avr32/dl-startup.h +++ b/ldso/ldso/avr32/dl-startup.h @@ -9,36 +9,36 @@ /* This is the library loader's main entry point. Let _dl_boot2 do its * initializations and jump to the application's entry point * afterwards. */ -asm( " .text\n" - " .global _start\n" - " .type _start,@function\n" - "_start:\n" - /* All arguments are on the stack initially */ - " mov r12, sp\n" - " rcall _dl_start\n" - /* Returns user entry point in r12. Save it. */ - " mov r0, r12\n" - /* We're PIC, so get the Global Offset Table */ - " lddpc r6, .L_GOT\n" - ".L_RGOT:\n" - " rsub r6, pc\n" - /* Adjust argc and argv according to _dl_skip_args */ - " ld.w r1, r6[_dl_skip_args@got]\n" - " ld.w r1, r1[0]\n" - " ld.w r2, sp++\n" - " sub r2, r1\n" - " add sp, sp, r1 << 2\n" - " st.w --sp, r2\n" - /* Load the finalizer function */ - " ld.w r12, r6[_dl_fini@got]\n" - /* Jump to the user's entry point */ - " mov pc, r0\n\n" +asm( " .text\n" + " .global _start\n" + " .type _start,@function\n" + "_start:\n" + /* All arguments are on the stack initially */ + " mov r12, sp\n" + " rcall _dl_start\n" + /* Returns user entry point in r12. Save it. */ + " mov r0, r12\n" + /* We're PIC, so get the Global Offset Table */ + " lddpc r6, .L_GOT\n" + ".L_RGOT:\n" + " rsub r6, pc\n" + /* Adjust argc and argv according to _dl_skip_args */ + " ld.w r1, r6[_dl_skip_args@got]\n" + " ld.w r1, r1[0]\n" + " ld.w r2, sp++\n" + " sub r2, r1\n" + " add sp, sp, r1 << 2\n" + " st.w --sp, r2\n" + /* Load the finalizer function */ + " ld.w r12, r6[_dl_fini@got]\n" + /* Jump to the user's entry point */ + " mov pc, r0\n\n" - " .align 2\n" - ".L_GOT:" - " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n" - " .size _start, . - _start\n" - " .previous\n"); + " .align 2\n" + ".L_GOT:" + " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n" + " .size _start, . - _start\n" + " .previous\n"); /* Get a pointer to the argv array. On many platforms this can be just * the address if the first argument, on other platforms we need to @@ -58,13 +58,13 @@ asm( " .text\n" static __always_inline void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt) { - Elf32_Addr i, nr_got; - register Elf32_Addr *__r6 __asm__("r6"); - Elf32_Addr *got = __r6; + Elf32_Addr i, nr_got; + register Elf32_Addr *__r6 __asm__("r6"); + Elf32_Addr *got = __r6; - nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got); - for (i = 2; i < nr_got; i++) - got[i] += tpnt->loadaddr; + nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got); + for (i = 2; i < nr_got; i++) + got[i] += tpnt->loadaddr; } #define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt) @@ -72,34 +72,34 @@ void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt) /* Handle relocation of the symbols in the dynamic loader. */ static __always_inline void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr, - unsigned long symbol_addr, - unsigned long load_addr, Elf32_Sym *symtab) + unsigned long symbol_addr, + unsigned long load_addr, Elf32_Sym *symtab) { - switch(ELF32_R_TYPE(rpnt->r_info)) { - case R_AVR32_NONE: - break; - case R_AVR32_GLOB_DAT: - case R_AVR32_JMP_SLOT: - *reloc_addr = symbol_addr; - break; - case R_AVR32_RELATIVE: - SEND_STDERR_DEBUG("Applying RELATIVE relocation: "); - SEND_ADDRESS_STDERR_DEBUG(load_addr, 0); - SEND_STDERR_DEBUG(" + "); - SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1); - *reloc_addr = load_addr + rpnt->r_addend; - break; - default: - SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type "); - SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1); - SEND_STDERR("REL, SYMBOL, LOAD: "); - SEND_ADDRESS_STDERR(reloc_addr, 0); - SEND_STDERR(", "); - SEND_ADDRESS_STDERR(symbol_addr, 0); - SEND_STDERR(", "); - SEND_ADDRESS_STDERR(load_addr, 1); - _dl_exit(1); - } + switch(ELF32_R_TYPE(rpnt->r_info)) { + case R_AVR32_NONE: + break; + case R_AVR32_GLOB_DAT: + case R_AVR32_JMP_SLOT: + *reloc_addr = symbol_addr; + break; + case R_AVR32_RELATIVE: + SEND_STDERR_DEBUG("Applying RELATIVE relocation: "); + SEND_ADDRESS_STDERR_DEBUG(load_addr, 0); + SEND_STDERR_DEBUG(" + "); + SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1); + *reloc_addr = load_addr + rpnt->r_addend; + break; + default: + SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type "); + SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1); + SEND_STDERR("REL, SYMBOL, LOAD: "); + SEND_ADDRESS_STDERR(reloc_addr, 0); + SEND_STDERR(", "); + SEND_ADDRESS_STDERR(symbol_addr, 0); + SEND_STDERR(", "); + SEND_ADDRESS_STDERR(load_addr, 1); + _dl_exit(1); + } } /* Transfer control to the user's application, once the dynamic loader @@ -109,4 +109,4 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr, * Since our _dl_boot will simply call whatever is returned by * _dl_boot2, we can just return the address we're supposed to * call. */ -#define START() return _dl_elf_main; +#define START() return _dl_elf_main; diff --git a/ldso/ldso/avr32/dl-sysdep.h b/ldso/ldso/avr32/dl-sysdep.h index 270800ade..1a301727b 100644 --- a/ldso/ldso/avr32/dl-sysdep.h +++ b/ldso/ldso/avr32/dl-sysdep.h @@ -13,29 +13,29 @@ #include <elf.h> #define ARCH_NUM 1 -#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM) +#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM) -#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \ - do { \ - if (dpnt->d_tag == DT_AVR32_GOTSZ) \ - dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \ - } while (0) +#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \ + do { \ + if (dpnt->d_tag == DT_AVR32_GOTSZ) \ + dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \ + } while (0) /* Initialization sequence for the application/library GOT. */ -#define INIT_GOT(GOT_BASE,MODULE) \ - do { \ - unsigned long i, nr_got; \ - \ - GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \ - GOT_BASE[1] = (unsigned long) MODULE; \ - \ - /* Add load address displacement to all GOT entries */ \ - nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \ - for (i = 2; i < nr_got; i++) \ - GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \ - } while (0) - -#define do_rem(result, n, base) ((result) = (n) % (base)) +#define INIT_GOT(GOT_BASE,MODULE) \ + do { \ + unsigned long i, nr_got; \ + \ + GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \ + GOT_BASE[1] = (unsigned long) MODULE; \ + \ + /* Add load address displacement to all GOT entries */ \ + nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \ + for (i = 2; i < nr_got; i++) \ + GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \ + } while (0) + +#define do_rem(result, n, base) ((result) = (n) % (base)) /* Here we define the magic numbers that this dynamic loader should accept */ #define MAGIC1 EM_AVR32 @@ -51,8 +51,8 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got); #define ADDR_ALIGN 0xfff #define OFFS_ALIGN 0x7ffff000 -#define elf_machine_type_class(type) \ - ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) +#define elf_machine_type_class(type) \ + ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) /* AVR32 doesn't need any COPY relocs */ #define DL_NO_COPY_RELOCS @@ -63,27 +63,27 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got); static inline Elf32_Addr elf_machine_dynamic (void) { - register Elf32_Addr *got asm ("r6"); - return *got; + register Elf32_Addr *got asm ("r6"); + return *got; } /* Return the run-time load address of the shared object. */ static inline Elf32_Addr elf_machine_load_address (void) { - extern void __dl_start asm("_dl_start"); - Elf32_Addr got_addr = (Elf32_Addr) &__dl_start; - Elf32_Addr pcrel_addr; - - asm (" lddpc %0, 2f\n" - "1: add %0, pc\n" - " rjmp 3f\n" - " .align 2\n" - "2: .long _dl_start - 1b\n" - "3:\n" - : "=r"(pcrel_addr) : : "cc"); - - return pcrel_addr - got_addr; + extern void __dl_start asm("_dl_start"); + Elf32_Addr got_addr = (Elf32_Addr) &__dl_start; + Elf32_Addr pcrel_addr; + + asm (" lddpc %0, 2f\n" + "1: add %0, pc\n" + " rjmp 3f\n" + " .align 2\n" + "2: .long _dl_start - 1b\n" + "3:\n" + : "=r"(pcrel_addr) : : "cc"); + + return pcrel_addr - got_addr; } /* @@ -93,13 +93,13 @@ elf_machine_load_address (void) */ static inline void elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr, - Elf32_Word relative_count) + Elf32_Word relative_count) { - Elf32_Rela *rpnt = (void *)rel_addr; + Elf32_Rela *rpnt = (void *)rel_addr; - do { - Elf32_Addr *reloc_addr; - reloc_addr = (void *)(load_off + (rpnt++)->r_offset); - *reloc_addr = load_off + rpnt->r_addend; - } while (--relative_count); + do { + Elf32_Addr *reloc_addr; + reloc_addr = (void *)(load_off + (rpnt++)->r_offset); + *reloc_addr = load_off + rpnt->r_addend; + } while (--relative_count); } diff --git a/ldso/ldso/avr32/elfinterp.c b/ldso/ldso/avr32/elfinterp.c index e236e4825..813179e64 100644 --- a/ldso/ldso/avr32/elfinterp.c +++ b/ldso/ldso/avr32/elfinterp.c @@ -29,165 +29,165 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got) { - /* - * AVR32 currently does not do lazy relocation. - */ + /* + * AVR32 currently does not do lazy relocation. + */ #if 0 - struct elf_resolve *tpnt = (struct elf_resolve *)got[1]; - Elf32_Sym *sym; - unsigned long local_gotno; - unsigned long gotsym; - unsigned long new_addr; - char *strtab, *symname; - unsigned long *entry; - unsigned long sym_index = got_offset / 4; - - local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO]; - gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM]; - - sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr)) - + sym_index; - strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); - symname = strtab + sym->st_name; - - new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name, - tpnt->symbol_scope, tpnt, - resolver); - - entry = (unsigned long *)(got + local_gotno + sym_index - gotsym); - *entry = new_addr; - - return new_addr; + struct elf_resolve *tpnt = (struct elf_resolve *)got[1]; + Elf32_Sym *sym; + unsigned long local_gotno; + unsigned long gotsym; + unsigned long new_addr; + char *strtab, *symname; + unsigned long *entry; + unsigned long sym_index = got_offset / 4; + + local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO]; + gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM]; + + sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr)) + + sym_index; + strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); + symname = strtab + sym->st_name; + + new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name, + tpnt->symbol_scope, tpnt, + resolver); + + entry = (unsigned long *)(got + local_gotno + sym_index - gotsym); + *entry = new_addr; + + return new_addr; #endif - return 0; + return 0; } static int _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, - unsigned long rel_addr, unsigned long rel_size, - int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope, - Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)) + unsigned long rel_addr, unsigned long rel_size, + int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope, + Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)) { - Elf32_Sym *symtab; - Elf32_Rela *rpnt; - char *strtab; - int i; + Elf32_Sym *symtab; + Elf32_Rela *rpnt; + char *strtab; + int i; - rpnt = (Elf32_Rela *)rel_addr; - rel_size /= sizeof(Elf32_Rela); - symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB]; - strtab = (char *)tpnt->dynamic_info[DT_STRTAB]; + rpnt = (Elf32_Rela *)rel_addr; + rel_size /= sizeof(Elf32_Rela); + symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB]; + strtab = (char *)tpnt->dynamic_info[DT_STRTAB]; - for (i = 0; i < rel_size; i++, rpnt++) { - int symtab_index, res; + for (i = 0; i < rel_size; i++, rpnt++) { + int symtab_index, res; - symtab_index = ELF32_R_SYM(rpnt->r_info); + symtab_index = ELF32_R_SYM(rpnt->r_info); - debug_sym(symtab, strtab, symtab_index); - debug_reloc(symtab, strtab, rpnt); + debug_sym(symtab, strtab, symtab_index); + debug_reloc(symtab, strtab, rpnt); - res = reloc_func(tpnt, scope, rpnt, symtab, strtab); + res = reloc_func(tpnt, scope, rpnt, symtab, strtab); - if (res == 0) - continue; + if (res == 0) + continue; - _dl_dprintf(2, "\n%s: ", _dl_progname); + _dl_dprintf(2, "\n%s: ", _dl_progname); - if (symtab_index) - _dl_dprintf(2, "symbol '%s': ", - strtab + symtab[symtab_index].st_name); + if (symtab_index) + _dl_dprintf(2, "symbol '%s': ", + strtab + symtab[symtab_index].st_name); - if (res < 0) { - int reloc_type = ELF32_R_TYPE(rpnt->r_info); + if (res < 0) { + int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined(__SUPPORT_LD_DEBUG__) - _dl_dprintf(2, "can't handle reloc type %s\n", - _dl_reltypes(reloc_type)); + _dl_dprintf(2, "can't handle reloc type %s\n", + _dl_reltypes(reloc_type)); #else - _dl_dprintf(2, "can't handle reloc type %x\n", - reloc_type); + _dl_dprintf(2, "can't handle reloc type %x\n", + reloc_type); #endif - _dl_exit(-res); - } else { - _dl_dprintf(2, "can't resolve symbol\n"); - return res; - } - } - - return 0; + _dl_exit(-res); + } else { + _dl_dprintf(2, "can't resolve symbol\n"); + return res; + } + } + + return 0; } static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope, - Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab) + Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab) { - int reloc_type; - int symtab_index; - char *symname; - unsigned long *reloc_addr; - unsigned long symbol_addr; + int reloc_type; + int symtab_index; + char *symname; + unsigned long *reloc_addr; + unsigned long symbol_addr; #if defined(__SUPPORT_LD_DEBUG__) - unsigned long old_val; + unsigned long old_val; #endif - reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset); - reloc_type = ELF32_R_TYPE(rpnt->r_info); - symtab_index = ELF32_R_SYM(rpnt->r_info); - symbol_addr = 0; - symname = strtab + symtab[symtab_index].st_name; - - if (symtab_index) { - symbol_addr = (unsigned long) - _dl_find_hash(strtab + symtab[symtab_index].st_name, - tpnt->symbol_scope, tpnt, - elf_machine_type_class(reloc_type)); - - /* Allow undefined references to weak symbols */ - if (!symbol_addr && - ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) { - _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", - _dl_progname, symname); - return 0; - } - } + reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset); + reloc_type = ELF32_R_TYPE(rpnt->r_info); + symtab_index = ELF32_R_SYM(rpnt->r_info); + symbol_addr = 0; + symname = strtab + symtab[symtab_index].st_name; + + if (symtab_index) { + symbol_addr = (unsigned long) + _dl_find_hash(strtab + symtab[symtab_index].st_name, + tpnt->symbol_scope, tpnt, + elf_machine_type_class(reloc_type)); + + /* Allow undefined references to weak symbols */ + if (!symbol_addr && + ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) { + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", + _dl_progname, symname); + return 0; + } + } #if defined(__SUPPORT_LD_DEBUG__) - old_val = *reloc_addr; + old_val = *reloc_addr; #endif - switch (reloc_type) { - case R_AVR32_NONE: - break; - case R_AVR32_GLOB_DAT: - case R_AVR32_JMP_SLOT: - *reloc_addr = symbol_addr + rpnt->r_addend; - break; - case R_AVR32_RELATIVE: - *reloc_addr = (unsigned long)tpnt->loadaddr - + rpnt->r_addend; - break; - default: - return -1; - } + switch (reloc_type) { + case R_AVR32_NONE: + break; + case R_AVR32_GLOB_DAT: + case R_AVR32_JMP_SLOT: + *reloc_addr = symbol_addr + rpnt->r_addend; + break; + case R_AVR32_RELATIVE: + *reloc_addr = (unsigned long)tpnt->loadaddr + + rpnt->r_addend; + break; + default: + return -1; + } #if defined(__SUPPORT_LD_DEBUG__) - if (_dl_debug_reloc && _dl_debug_detail) - _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", - old_val, *reloc_addr); + if (_dl_debug_reloc && _dl_debug_detail) + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", + old_val, *reloc_addr); #endif - return 0; + return 0; } void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt, - unsigned long rel_addr, - unsigned long rel_size) + unsigned long rel_addr, + unsigned long rel_size) { - /* TODO: Might want to support this in order to get faster - * startup times... */ + /* TODO: Might want to support this in order to get faster + * startup times... */ } int _dl_parse_relocation_information(struct dyn_elf *rpnt, - unsigned long rel_addr, - unsigned long rel_size) + unsigned long rel_addr, + unsigned long rel_size) { - return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, - _dl_do_reloc); + return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, + _dl_do_reloc); } diff --git a/ldso/ldso/avr32/resolve.S b/ldso/ldso/avr32/resolve.S index ad90c2548..e3cb7f4d1 100644 --- a/ldso/ldso/avr32/resolve.S +++ b/ldso/ldso/avr32/resolve.S @@ -11,18 +11,18 @@ #define ip r5 - .text - .global _dl_linux_resolve - .type _dl_linux_resolve,@function + .text + .global _dl_linux_resolve + .type _dl_linux_resolve,@function _dl_linux_resolve: - /* The PLT code pushed r8 for us. It contains the address of this - function's GOT entry, that is entry 0. ip contains the address - of the GOT entry of the function we wanted to call. */ - stm --sp, r9-r12, lr - mov r11, r8 - sub r12, ip, r8 - rcall _dl_linux_resolver - mov ip, r12 - popm r8-r12,lr - mov pc, ip - .size _dl_linux_resolve, . - _dl_linux_resolve + /* The PLT code pushed r8 for us. It contains the address of this + function's GOT entry, that is entry 0. ip contains the address + of the GOT entry of the function we wanted to call. */ + stm --sp, r9-r12, lr + mov r11, r8 + sub r12, ip, r8 + rcall _dl_linux_resolver + mov ip, r12 + popm r8-r12,lr + mov pc, ip + .size _dl_linux_resolve, . - _dl_linux_resolve |