diff options
-rw-r--r-- | ldso/ldso/bfin/dl-inlines.h | 55 | ||||
-rw-r--r-- | ldso/ldso/bfin/dl-startup.h | 14 | ||||
-rw-r--r-- | ldso/ldso/bfin/dl-sysdep.h | 17 | ||||
-rw-r--r-- | ldso/ldso/bfin/elfinterp.c | 10 | ||||
-rw-r--r-- | ldso/ldso/i386/dl-startup.h | 1 | ||||
-rw-r--r-- | ldso/ldso/i386/dl-sysdep.h | 60 | ||||
-rw-r--r-- | ldso/ldso/i386/resolve.S | 1 | ||||
-rw-r--r-- | ldso/ldso/powerpc/elfinterp.c | 2 | ||||
-rw-r--r-- | ldso/ldso/sparc/dl-startup.h | 1 | ||||
-rw-r--r-- | ldso/ldso/sparc/dl-sysdep.h | 6 | ||||
-rw-r--r-- | ldso/ldso/x86_64/dl-startup.h | 1 | ||||
-rw-r--r-- | ldso/ldso/x86_64/resolve.S | 1 |
12 files changed, 72 insertions, 97 deletions
diff --git a/ldso/ldso/bfin/dl-inlines.h b/ldso/ldso/bfin/dl-inlines.h index 0a97065de..18f366873 100644 --- a/ldso/ldso/bfin/dl-inlines.h +++ b/ldso/ldso/bfin/dl-inlines.h @@ -18,7 +18,7 @@ License along with uClibc; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <bits/bfin_sram.h> +#include <bfin_sram.h> #ifndef _dl_assert # define _dl_assert(expr) @@ -463,6 +463,17 @@ __dl_loadaddr_unmap (struct elf32_fdpic_loadaddr loadaddr, struct elf32_fdpic_loadseg *segdata; ssize_t offs; segdata = loadaddr.map->segs + i; + + /* FIXME: + A more cleaner way is to add type for struct elf32_fdpic_loadseg, + and release the memory according to the type. + Currently, we hardcode the memory address of L1 SRAM. */ + if ((segdata->addr & 0xff800000) == 0xff800000) + { + _dl_sram_free ((void *)segdata->addr); + continue; + } + offs = (segdata->p_vaddr & ADDR_ALIGN); _dl_munmap ((void*)segdata->addr - offs, segdata->p_memsz + offs); @@ -493,7 +504,15 @@ __dl_is_special_segment (Elf32_Ehdr *epnt, && !(ppnt->p_flags & PF_X)) return 1; - return 0; + /* 0xff700000, 0xff800000, 0xff900000 and 0xffa00000 are also used in + GNU ld and linux kernel. They need to be keep synchronized. */ + if (ppnt->p_vaddr == 0xff700000 + || ppnt->p_vaddr == 0xff800000 + || ppnt->p_vaddr == 0xff900000 + || ppnt->p_vaddr == 0xffa00000) + return 1; + + return 0; } inline static char * @@ -505,7 +524,7 @@ __dl_map_segment (Elf32_Ehdr *epnt, char *status, *tryaddr, *l1addr; size_t size; - if ((epnt->e_flags & EF_BFIN_CODE_IN_L1) + if (((epnt->e_flags & EF_BFIN_CODE_IN_L1) || ppnt->p_vaddr == 0xffa00000) && !(ppnt->p_flags & PF_W) && (ppnt->p_flags & PF_X)) { status = (char *) _dl_mmap @@ -522,20 +541,32 @@ __dl_map_segment (Elf32_Ehdr *epnt, _dl_dma_memcpy (l1addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz); _dl_munmap (status, size); if (l1addr == NULL) - return NULL; + _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__); return l1addr; } - if ((epnt->e_flags & EF_BFIN_DATA_IN_L1) + if (((epnt->e_flags & EF_BFIN_DATA_IN_L1) + || ppnt->p_vaddr == 0xff700000 + || ppnt->p_vaddr == 0xff800000 + || ppnt->p_vaddr == 0xff900000) && (ppnt->p_flags & PF_W) && !(ppnt->p_flags & PF_X)) { - l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM); - if (l1addr == NULL - || (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) - != ppnt->p_filesz)) - return NULL; - if (ppnt->p_filesz < ppnt->p_memsz) - _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz); + if (ppnt->p_vaddr == 0xff800000) + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_A_SRAM); + else if (ppnt->p_vaddr == 0xff900000) + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_B_SRAM); + else + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM); + if (l1addr == NULL) { + _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__); + } else { + if (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) { + _dl_sram_free (l1addr); + return NULL; + } + if (ppnt->p_filesz < ppnt->p_memsz) + _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz); + } return l1addr; } diff --git a/ldso/ldso/bfin/dl-startup.h b/ldso/ldso/bfin/dl-startup.h index 09f946e9f..5b596fd01 100644 --- a/ldso/ldso/bfin/dl-startup.h +++ b/ldso/ldso/bfin/dl-startup.h @@ -86,7 +86,8 @@ __asm__( " .size __dl_boot,.-__dl_boot\n" ); -#define DL_BOOT(X) \ +#undef DL_START +#define DL_START(X) \ static void __attribute__ ((used)) \ _dl_start (Elf32_Addr dl_boot_got_pointer, \ struct elf32_fdpic_loadmap *dl_boot_progmap, \ @@ -105,17 +106,6 @@ struct elf32_fdpic_loadmap; #define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1) /* - * Compute the GOT address. On several platforms, we use assembly - * here. on FR-V FDPIC, there's no way to compute the GOT address, - * since the offset between text and data is not fixed, so we arrange - * for the assembly _dl_boot to pass this value as an argument to - * _dl_boot. */ -#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer) - -#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \ - ((dpnt) = dl_boot_ldso_dyn_pointer) - -/* * Here is a macro to perform a relocation. This is only used when * bootstrapping the dynamic loader. RELP is the relocation that we * are performing, REL is the pointer to the address we are relocating. diff --git a/ldso/ldso/bfin/dl-sysdep.h b/ldso/ldso/bfin/dl-sysdep.h index 0376c6151..38ed51300 100644 --- a/ldso/ldso/bfin/dl-sysdep.h +++ b/ldso/ldso/bfin/dl-sysdep.h @@ -34,6 +34,8 @@ USA. */ #define DL_NO_COPY_RELOCS +#define HAVE_DL_INLINES_H + /* * Initialization sequence for a GOT. Copy the resolver function * descriptor and the pointer to the elf_resolve/link_map data @@ -93,7 +95,7 @@ struct funcdesc_ht; #define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr #define DL_RELOC_ADDR(LOADADDR, ADDR) \ - (__reloc_pointer ((void*)(ADDR), (LOADADDR).map)) + ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map)) #define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \ ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value)) @@ -136,6 +138,17 @@ struct funcdesc_ht; #define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \ (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr)) +/* + * Compute the GOT address. On several platforms, we use assembly + * here. on FR-V FDPIC, there's no way to compute the GOT address, + * since the offset between text and data is not fixed, so we arrange + * for the assembly _dl_boot to pass this value as an argument to + * _dl_boot. */ +#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer) + +#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \ + ((dpnt) = dl_boot_ldso_dyn_pointer) + /* We only support loading FDPIC independently-relocatable shared libraries. It probably wouldn't be too hard to support loading shared libraries that require relocation by the same amount, but we @@ -176,7 +189,7 @@ while (0) #define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \ (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \ && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \ - ? _dl_funcdesc_for (DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \ + ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \ (TPNT)->loadaddr.got_value) \ : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value)) diff --git a/ldso/ldso/bfin/elfinterp.c b/ldso/ldso/bfin/elfinterp.c index 792c45c21..d003e2e71 100644 --- a/ldso/ldso/bfin/elfinterp.c +++ b/ldso/ldso/bfin/elfinterp.c @@ -72,11 +72,9 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry) got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset); /* Get the address to be used to fill in the GOT entry. */ - new_addr = _dl_find_hash_mod(symname, tpnt->symbol_scope, NULL, 0, - &new_tpnt); + new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt); if (!new_addr) { - new_addr = _dl_find_hash_mod(symname, NULL, NULL, 0, - &new_tpnt); + new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt); if (!new_addr) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); @@ -188,7 +186,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, } else { symbol_addr = (unsigned long) - _dl_find_hash_mod(symname, scope, NULL, 0, &symbol_tpnt); + _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt); /* * We want to allow undefined references to weak symbols - this might @@ -346,7 +344,7 @@ _dl_parse_copy_information return 0; } -#ifndef LIBDL +#ifndef IS_IN_libdl # include "../../libc/sysdeps/linux/bfin/crtreloc.c" #endif diff --git a/ldso/ldso/i386/dl-startup.h b/ldso/ldso/i386/dl-startup.h index 933c22c1e..45f69b85d 100644 --- a/ldso/ldso/i386/dl-startup.h +++ b/ldso/ldso/i386/dl-startup.h @@ -5,7 +5,6 @@ */ __asm__ ( " .text\n" - " .align 16\n" " .globl _start\n" " .type _start,@function\n" "_start:\n" diff --git a/ldso/ldso/i386/dl-sysdep.h b/ldso/ldso/i386/dl-sysdep.h index eabe66204..931abe305 100644 --- a/ldso/ldso/i386/dl-sysdep.h +++ b/ldso/ldso/i386/dl-sysdep.h @@ -59,7 +59,6 @@ elf_machine_load_address (void) /* It doesn't matter what variable this is, the reference never makes it to assembly. We need a dummy reference to some global variable via the GOT to make sure the compiler initialized %ebx in time. */ - extern int _dl_errno; Elf32_Addr addr; __asm__ ("leal _dl_start@GOTOFF(%%ebx), %0\n" "subl _dl_start@GOT(%%ebx), %0" @@ -79,62 +78,3 @@ elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr, *reloc_addr += load_off; } while (--relative_count); } - -/* - * These were taken from the 'dl-sysdep.h' files in the 'nptl' directory - * in glibc. - */ -#if USE_TLS -# ifdef CONFIG_686 -/* Traditionally system calls have been made using int $0x80. A - second method was introduced which, if possible, will use the - sysenter/syscall instructions. To signal the presence and where to - find the code the kernel passes an AT_SYSINFO value in the - auxiliary vector to the application. */ -# define NEED_DL_SYSINFO 1 -# define USE_DL_SYSINFO 1 - -# if defined NEED_DL_SYSINFO && !defined __ASSEMBLER__ -extern void _dl_sysinfo_int80 (void) attribute_hidden; -# define DL_SYSINFO_DEFAULT (uintptr_t) _dl_sysinfo_int80 -# define DL_SYSINFO_IMPLEMENTATION \ - asm (".text\n\t" \ - ".type _dl_sysinfo_int80,@function\n\t" \ - ".hidden _dl_sysinfo_int80\n" \ - CFI_STARTPROC "\n" \ - "_dl_sysinfo_int80:\n\t" \ - "int $0x80;\n\t" \ - "ret;\n\t" \ - CFI_ENDPROC "\n" \ - ".size _dl_sysinfo_int80,.-_dl_sysinfo_int80\n\t" \ - ".previous"); -# endif -# else -/* Traditionally system calls have been made using int $0x80. A - second method was introduced which, if possible, will use the - sysenter/syscall instructions. To signal the presence and where to - find the code the kernel passes an AT_SYSINFO value in the - auxiliary vector to the application. - sysenter/syscall is not useful on i386 through i586, but the dynamic - linker and dl code in libc.a has to be able to load i686 compiled - libraries. */ -# define NEED_DL_SYSINFO 1 -# undef USE_DL_SYSINFO - -# if defined NEED_DL_SYSINFO && !defined __ASSEMBLER__ -extern void _dl_sysinfo_int80 (void) attribute_hidden; -# define DL_SYSINFO_DEFAULT (uintptr_t) _dl_sysinfo_int80 -# define DL_SYSINFO_IMPLEMENTATION \ - asm (".text\n\t" \ - ".type _dl_sysinfo_int80,@function\n\t" \ - ".hidden _dl_sysinfo_int80\n\t" \ - CFI_STARTPROC "\n" \ - "_dl_sysinfo_int80:\n\t" \ - "int $0x80;\n\t" \ - "ret;\n\t" \ - CFI_ENDPROC "\n" \ - ".size _dl_sysinfo_int80,.-_dl_sysinfo_int80\n\t" \ - ".previous;"); -# endif -# endif /* CONFIG_686 */ -#endif /* USE_TLS */ diff --git a/ldso/ldso/i386/resolve.S b/ldso/ldso/i386/resolve.S index c9880999c..e8d77bb1d 100644 --- a/ldso/ldso/i386/resolve.S +++ b/ldso/ldso/i386/resolve.S @@ -21,7 +21,6 @@ */ .text -.align 4 .globl _dl_linux_resolve .type _dl_linux_resolve,@function diff --git a/ldso/ldso/powerpc/elfinterp.c b/ldso/ldso/powerpc/elfinterp.c index b48625a37..8953e7059 100644 --- a/ldso/ldso/powerpc/elfinterp.c +++ b/ldso/ldso/powerpc/elfinterp.c @@ -213,7 +213,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, * here, so all bases should be covered. */ if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) - return -1; + return 1; } #if defined (__SUPPORT_LD_DEBUG__) old_val = *reloc_addr; diff --git a/ldso/ldso/sparc/dl-startup.h b/ldso/ldso/sparc/dl-startup.h index 7da972269..4ceb7c55a 100644 --- a/ldso/ldso/sparc/dl-startup.h +++ b/ldso/ldso/sparc/dl-startup.h @@ -9,6 +9,7 @@ asm ("\ .global _start\n\ .type _start,%function\n\ .align 32\n\ + .register %g2, #scratch\n\ _start:\n\ /* Allocate space for functions to drop their arguments. */\n\ sub %sp, 6*4, %sp\n\ diff --git a/ldso/ldso/sparc/dl-sysdep.h b/ldso/ldso/sparc/dl-sysdep.h index 12973e1be..4ec2c37d9 100644 --- a/ldso/ldso/sparc/dl-sysdep.h +++ b/ldso/ldso/sparc/dl-sysdep.h @@ -83,10 +83,16 @@ sparc_mod(unsigned long m, unsigned long p) #endif /* 4096 bytes alignment */ +#if defined(__sparc_v9__) /* ...but 8192 is required for mmap() on sparc64 kernel */ #define PAGE_ALIGN 0xffffe000 #define ADDR_ALIGN 0x1fff #define OFFS_ALIGN 0x7fffe000 +#elif defined(__sparc_v8__) +#define PAGE_ALIGN 0xfffff000 +#define ADDR_ALIGN 0xfff +#define OFFS_ALIGN 0x7ffff000 +#endif /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so PLT entries should not be allowed to define the value. diff --git a/ldso/ldso/x86_64/dl-startup.h b/ldso/ldso/x86_64/dl-startup.h index c9a0aac7a..6da888068 100644 --- a/ldso/ldso/x86_64/dl-startup.h +++ b/ldso/ldso/x86_64/dl-startup.h @@ -8,7 +8,6 @@ */ __asm__ ( " .text\n" - " .align 16\n" " .global _start\n" " .type _start,%function\n" "_start:\n" diff --git a/ldso/ldso/x86_64/resolve.S b/ldso/ldso/x86_64/resolve.S index 5d55d0c73..ac1d1822f 100644 --- a/ldso/ldso/x86_64/resolve.S +++ b/ldso/ldso/x86_64/resolve.S @@ -26,7 +26,6 @@ .global _dl_linux_resolve .type _dl_linux_resolve,%function -.align 16 _dl_linux_resolve: subq $56,%rsp |