OSDN Git Service

Merge remote-tracking branch 'origin/master' into prelink
authorCarmelo Amoroso <carmelo.amoroso@st.com>
Wed, 4 May 2011 06:31:16 +0000 (08:31 +0200)
committerCarmelo Amoroso <carmelo.amoroso@st.com>
Wed, 4 May 2011 06:31:16 +0000 (08:31 +0200)
* origin/master: (32 commits)
  libubacktrace: fix backtrace support on arm-eabi, which needs libgcc_eh linked too
  getaddrinfo.c: fix incorrect check for ERANGE from gethostbyaddr_r
  getaddrinfo.c: improve code readability. No functional changes
  string: remove unused variable
  x86_64: silence warning if !TLS
  buildsys: prettify ssp.c handling
  madvise is LINUX_SPECIFIC
  test_nptl: fix expected result for tst-cputimer[123]
  test_nptl: fix expected result for tst-clock2 test
  buildsys: make $(LOCAL_INSTALL_PATH) phony
  ether_aton: reject invalid input
  tests: disable ether tests if !HAS_SOCKET
  inet: add ether_aton testcase
  sysconf: clock_getres depends on HAS_REALTIME
  __rt_sigwaitinfo: depends on HAS_REALTIME
  buildsys: minor fixes in Makefile.arch for C6X
  buildsys: minor fixes in Makefile.arch for microblaze
  libubacktrace: enabled for all archs indeed.
  sparc: don't access fp registers when configured for no fpu
  libubacktrace: generic implementation based dwarf
  ...

Conflicts:
ldso/ldso/dl-elf.c
ldso/ldso/mips/elfinterp.c
ldso/ldso/x86_64/elfinterp.c

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
1  2 
extra/Configs/Config.in
ldso/include/dl-elf.h
ldso/include/ldso.h
ldso/ldso/dl-elf.c
ldso/ldso/dl-startup.c
ldso/ldso/mips/elfinterp.c
ldso/ldso/x86_64/elfinterp.c

Simple merge
Simple merge
Simple merge
@@@ -517,142 -629,16 +636,10 @@@ struct elf_resolve *_dl_load_elf_shared
                        char *tryaddr;
                        ssize_t size;
  
 -                      /* See if this is a PIC library. */
 -                      if (i == 0 && ppnt->p_vaddr > 0x1000000) {
 -                              piclib = 0;
 -                              /* flags |= MAP_FIXED; */
 -                      }
 -
                        if (ppnt->p_flags & PF_W) {
-                               unsigned long map_size;
-                               char *cpnt;
-                               char *piclib2map = 0;
-                               if (piclib == 2 &&
-                                   /* We might be able to avoid this
-                                      call if memsz doesn't require
-                                      an additional page, but this
-                                      would require mmap to always
-                                      return page-aligned addresses
-                                      and a whole number of pages
-                                      allocated.  Unfortunately on
-                                      uClinux may return misaligned
-                                      addresses and may allocate
-                                      partial pages, so we may end up
-                                      doing unnecessary mmap calls.
-                                      This is what we could do if we
-                                      knew mmap would always return
-                                      aligned pages:
-                                   ((ppnt->p_vaddr + ppnt->p_filesz
-                                     + ADDR_ALIGN)
-                                    & PAGE_ALIGN)
-                                   < ppnt->p_vaddr + ppnt->p_memsz)
-                                      Instead, we have to do this:  */
-                                   ppnt->p_filesz < ppnt->p_memsz)
-                                 {
-                                   piclib2map = (char *)
-                                     _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN)
-                                              + ppnt->p_memsz,
-                                              LXFLAGS(ppnt->p_flags),
-                                              flags | MAP_ANONYMOUS, -1, 0);
-                                   if (_dl_mmap_check_error(piclib2map))
-                                     goto cant_map;
-                                   DL_INIT_LOADADDR_HDR
-                                     (lib_loadaddr, piclib2map
-                                      + (ppnt->p_vaddr & ADDR_ALIGN), ppnt);
-                                 }
-                               tryaddr = piclib == 2 ? piclib2map
-                                 : ((char*) (piclib ? libaddr : lib_loadaddr) +
-                                    (ppnt->p_vaddr & PAGE_ALIGN));
-                               size = (ppnt->p_vaddr & ADDR_ALIGN)
-                                 + ppnt->p_filesz;
-                               /* For !MMU, mmap to fixed address will fail.
-                                  So instead of desperately call mmap and fail,
-                                  we set status to MAP_FAILED to save a call
-                                  to mmap ().  */
- #ifndef __ARCH_USE_MMU__
-                               if (piclib2map == 0)
- #endif
-                                 status = (char *) _dl_mmap
-                                   (tryaddr, size, LXFLAGS(ppnt->p_flags),
-                                    flags | (piclib2map ? MAP_FIXED : 0),
-                                    infile, ppnt->p_offset & OFFS_ALIGN);
- #ifndef __ARCH_USE_MMU__
-                               else
-                                 status = MAP_FAILED;
- #endif
- #ifdef _DL_PREAD
-                               if (_dl_mmap_check_error(status) && piclib2map
-                                   && (_DL_PREAD (infile, tryaddr, size,
-                                                  ppnt->p_offset & OFFS_ALIGN)
-                                       == size))
-                                 status = tryaddr;
- #endif
-                               if (_dl_mmap_check_error(status)
-                                   || (tryaddr && tryaddr != status)) {
-                               cant_map:
-                                       _dl_dprintf(2, "%s:%i: can't map '%s'\n",
-                                                       _dl_progname, __LINE__, libname);
-                                       _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
-                                       DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma);
-                                       _dl_close(infile);
-                                       _dl_munmap(header, _dl_pagesize);
-                                       return NULL;
-                               }
-                               if (! piclib2map) {
-                                 DL_INIT_LOADADDR_HDR
-                                   (lib_loadaddr, status
-                                    + (ppnt->p_vaddr & ADDR_ALIGN), ppnt);
-                               }
-                               /* Now we want to allocate and
-                                  zero-out any data from the end of
-                                  the region we mapped in from the
-                                  file (filesz) to the end of the
-                                  loadable segment (memsz).  We may
-                                  need additional pages for memsz,
-                                  that we map in below, and we can
-                                  count on the kernel to zero them
-                                  out, but we have to zero out stuff
-                                  in the last page that we mapped in
-                                  from the file.  However, we can't
-                                  assume to have actually obtained
-                                  full pages from the kernel, since
-                                  we didn't ask for them, and uClibc
-                                  may not give us full pages for
-                                  small allocations.  So only zero
-                                  out up to memsz or the end of the
-                                  page, whichever comes first.  */
-                               /* CPNT is the beginning of the memsz
-                                  portion not backed by filesz.  */
-                               cpnt = (char *) (status + size);
-                               /* MAP_SIZE is the address of the
-                                  beginning of the next page.  */
-                               map_size = (ppnt->p_vaddr + ppnt->p_filesz
-                                           + ADDR_ALIGN) & PAGE_ALIGN;
- #ifndef MIN
- # define MIN(a,b) ((a) < (b) ? (a) : (b))
- #endif
-                               _dl_memset (cpnt, 0,
-                                           MIN (map_size
-                                                - (ppnt->p_vaddr
-                                                   + ppnt->p_filesz),
-                                                ppnt->p_memsz
-                                                - ppnt->p_filesz));
-                               if (map_size < ppnt->p_vaddr + ppnt->p_memsz
-                                   && !piclib2map) {
-                                       tryaddr = map_size + (char*)(piclib ? libaddr : lib_loadaddr);
-                                       status = (char *) _dl_mmap(tryaddr,
-                                               ppnt->p_vaddr + ppnt->p_memsz - map_size,
-                                               LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
-                                       if (_dl_mmap_check_error(status)
-                                           || tryaddr != status)
-                                               goto cant_map;
-                               }
+                               status = map_writeable (infile, ppnt, piclib, flags, libaddr);
+                               if (status == NULL)
+                                       goto cant_map1;
                        } else {
                                tryaddr = (piclib == 2 ? 0
                                           : (char *) (ppnt->p_vaddr & PAGE_ALIGN)
                }
                ppnt++;
        }
-       _dl_close(infile);
  
 -      /* For a non-PIC library, the addresses are all absolute */
 -      if (piclib) {
 +      /*
 +       * The dynamic_addr must be take into acount lib_loadaddr value, to note
 +       * it is zero when the SO has been mapped to the elf's physical addr
 +       */
 +      if (lib_loadaddr) {
                dynamic_addr = (unsigned long) DL_RELOC_ADDR(lib_loadaddr, dynamic_addr);
        }
  
                ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
                for (i = 0; i < epnt->e_phnum; i++, ppnt++) {
                        if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) {
 -                              _dl_mprotect((void *) ((piclib ? libaddr : 0) +
+ #ifdef __ARCH_USE_MMU__
 +                              _dl_mprotect((void *) ((piclib ? libaddr : lib_loadaddr) +
                                                        (ppnt->p_vaddr & PAGE_ALIGN)),
                                                (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz,
                                                PROT_READ | PROT_WRITE | PROT_EXEC);
  #endif
        }
  
+       _dl_close(infile);
        tpnt = _dl_add_elf_hash_table(libname, lib_loadaddr, dynamic_info,
                        dynamic_addr, 0);
 +      tpnt->mapaddr = libaddr;
        tpnt->relro_addr = relro_addr;
        tpnt->relro_size = relro_size;
        tpnt->st_dev = st.st_dev;
Simple merge
@@@ -381,8 -378,11 +381,11 @@@ void _dl_perform_mips_global_got_reloca
                                        *got_entry += (unsigned long) tpnt->loadaddr;
                        }
                        else {
+                               struct symbol_ref sym_ref;
+                               sym_ref.sym = sym;
+                               sym_ref.tpnt = NULL;
                                *got_entry = (unsigned long) _dl_find_hash(strtab +
-                                       sym->st_name, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
 -                                      sym->st_name, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, &sym_ref);
++                                      sym->st_name, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, &sym_ref);
                        }
  
                        got_entry++;
@@@ -186,18 -188,20 +188,22 @@@ _dl_do_reloc(struct elf_resolve *tpnt, 
                        /* This may be non-fatal if called from dlopen. */
                        return 1;
                }
 +              if (_dl_trace_prelink)
 +                      _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
 +                                              &sym_ref, elf_machine_type_class(reloc_type));
+ #if defined USE_TLS && USE_TLS
                tls_tpnt = sym_ref.tpnt;
+ #endif
        } else {
                /* Relocs against STN_UNDEF are usually treated as using a
                 * symbol value of zero, and using the module containing the
                 * reloc itself. */
                symbol_addr = sym_ref.sym->st_value;
+ #if defined USE_TLS && USE_TLS
                tls_tpnt = tpnt;
+ #endif
        }
  
 -
  #if defined (__SUPPORT_LD_DEBUG__)
        old_val = *reloc_addr;
  #endif