summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2012-03-16 15:37:57 -0700
committerBen Cheng <bccheng@google.com>2012-03-21 12:12:35 -0700
commitfac061ffdea9dc61a3b7c53cb85a44594a4354ba (patch)
tree7198df25ceaeb1e04b20c6d740703deface15190
parentcc6695e2684ce93cdf8bd2da63d55d2cf49ff076 (diff)
downloadandroid_external_elfutils-fac061ffdea9dc61a3b7c53cb85a44594a4354ba.tar.gz
android_external_elfutils-fac061ffdea9dc61a3b7c53cb85a44594a4354ba.tar.bz2
android_external_elfutils-fac061ffdea9dc61a3b7c53cb85a44594a4354ba.zip
Add new build rules and associated fixes needed by perf.
New static libraries (host and target): libelf, libebl, libdw, and libdwfl Cleaned up off_t, loff_t, and off64_t usage. Change-Id: Ic567dce0591aad3c9c61f4054b2e1948b0865d64
-rwxr-xr-xAndroid.mk156
-rw-r--r--android.patch330
-rw-r--r--bionic-fixup/AndroidFixup.h87
-rw-r--r--bionic-fixup/error.h36
-rw-r--r--bionic-fixup/getline.c49
-rw-r--r--bionic-fixup/libintl.h22
-rw-r--r--bionic-fixup/stdio_ext.h22
-rw-r--r--host-darwin-fixup/AndroidFixup.h20
-rw-r--r--host-darwin-fixup/byteswap.h16
-rw-r--r--host-darwin-fixup/endian.h16
-rw-r--r--host-darwin-fixup/error.h22
-rw-r--r--host-darwin-fixup/libintl.h16
-rw-r--r--host-linux-fixup/AndroidFixup.h18
-rwxr-xr-xlibdw/Android.mk176
-rw-r--r--libdw/dwarf_getpubnames.c6
-rw-r--r--libdw/dwarf_getsrc_file.c1
-rwxr-xr-xlibdwfl/Android.mk104
-rw-r--r--libdwfl/dwfl_build_id_find_elf.c4
-rw-r--r--libdwfl/dwfl_error.c7
-rw-r--r--libdwfl/dwfl_module_build_id.c1
-rw-r--r--libdwfl/dwfl_module_getdwarf.c4
-rw-r--r--libdwfl/dwfl_module_getsrc_file.c1
-rw-r--r--libdwfl/find-debuginfo.c4
-rw-r--r--libdwfl/offline.c4
-rwxr-xr-xlibebl/Android.mk123
-rw-r--r--libebl/eblopenbackend.c11
-rwxr-xr-xlibelf/Android.mk193
-rw-r--r--libelf/elf_getdata_rawchunk.c13
-rw-r--r--libelf/libelf.h40
29 files changed, 1247 insertions, 255 deletions
diff --git a/Android.mk b/Android.mk
index 3a885fdc..e790e1eb 100755
--- a/Android.mk
+++ b/Android.mk
@@ -1,147 +1,15 @@
-LOCAL_PATH := $(call my-dir)
-
-supported_platforms := linux-x86 darwin-x86
-cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
-
-ifdef cur_platform
+# Copyright (C) 2012 The Android Open Source Project
#
-# host libelf
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-include $(CLEAR_VARS)
-
-LIBELF_SRC_FILES := \
- libelf/elf32_checksum.c \
- libelf/elf32_fsize.c \
- libelf/elf32_getehdr.c \
- libelf/elf32_getphdr.c \
- libelf/elf32_getshdr.c \
- libelf/elf32_newehdr.c \
- libelf/elf32_newphdr.c \
- libelf/elf32_offscn.c \
- libelf/elf32_updatefile.c \
- libelf/elf32_updatenull.c \
- libelf/elf32_xlatetof.c \
- libelf/elf32_xlatetom.c \
- libelf/elf64_checksum.c \
- libelf/elf64_fsize.c \
- libelf/elf64_getehdr.c \
- libelf/elf64_getphdr.c \
- libelf/elf64_getshdr.c \
- libelf/elf64_newehdr.c \
- libelf/elf64_newphdr.c \
- libelf/elf64_offscn.c \
- libelf/elf64_updatefile.c \
- libelf/elf64_updatenull.c \
- libelf/elf64_xlatetof.c \
- libelf/elf64_xlatetom.c \
- libelf/elf_begin.c \
- libelf/elf_clone.c \
- libelf/elf_cntl.c \
- libelf/elf_end.c \
- libelf/elf_error.c \
- libelf/elf_fill.c \
- libelf/elf_flagdata.c \
- libelf/elf_flagehdr.c \
- libelf/elf_flagelf.c \
- libelf/elf_flagphdr.c \
- libelf/elf_flagscn.c \
- libelf/elf_flagshdr.c \
- libelf/elf_getarhdr.c \
- libelf/elf_getaroff.c \
- libelf/elf_getarsym.c \
- libelf/elf_getbase.c \
- libelf/elf_getdata.c \
- libelf/elf_getdata_rawchunk.c \
- libelf/elf_getident.c \
- libelf/elf_getscn.c \
- libelf/elf_getshnum.c \
- libelf/elf_getshstrndx.c \
- libelf/elf_gnu_hash.c \
- libelf/elf_hash.c \
- libelf/elf_kind.c \
- libelf/elf_memory.c \
- libelf/elf_ndxscn.c \
- libelf/elf_newdata.c \
- libelf/elf_newscn.c \
- libelf/elf_next.c \
- libelf/elf_nextscn.c \
- libelf/elf_rand.c \
- libelf/elf_rawdata.c \
- libelf/elf_rawfile.c \
- libelf/elf_readall.c \
- libelf/elf_scnshndx.c \
- libelf/elf_strptr.c \
- libelf/elf_update.c \
- libelf/elf_version.c \
- libelf/gelf_checksum.c \
- libelf/gelf_fsize.c \
- libelf/gelf_getauxv.c \
- libelf/gelf_getclass.c \
- libelf/gelf_getdyn.c \
- libelf/gelf_getehdr.c \
- libelf/gelf_getlib.c \
- libelf/gelf_getmove.c \
- libelf/gelf_getnote.c \
- libelf/gelf_getphdr.c \
- libelf/gelf_getrela.c \
- libelf/gelf_getrel.c \
- libelf/gelf_getshdr.c \
- libelf/gelf_getsym.c \
- libelf/gelf_getsyminfo.c \
- libelf/gelf_getsymshndx.c \
- libelf/gelf_getverdaux.c \
- libelf/gelf_getverdef.c \
- libelf/gelf_getvernaux.c \
- libelf/gelf_getverneed.c \
- libelf/gelf_getversym.c \
- libelf/gelf_newehdr.c \
- libelf/gelf_newphdr.c \
- libelf/gelf_offscn.c \
- libelf/gelf_update_auxv.c \
- libelf/gelf_update_dyn.c \
- libelf/gelf_update_ehdr.c \
- libelf/gelf_update_lib.c \
- libelf/gelf_update_move.c \
- libelf/gelf_update_phdr.c \
- libelf/gelf_update_rela.c \
- libelf/gelf_update_rel.c \
- libelf/gelf_update_shdr.c \
- libelf/gelf_update_sym.c \
- libelf/gelf_update_syminfo.c \
- libelf/gelf_update_symshndx.c \
- libelf/gelf_update_verdaux.c \
- libelf/gelf_update_verdef.c \
- libelf/gelf_update_vernaux.c \
- libelf/gelf_update_verneed.c \
- libelf/gelf_update_versym.c \
- libelf/gelf_xlate.c \
- libelf/gelf_xlatetof.c \
- libelf/gelf_xlatetom.c \
- libelf/libelf_crc32.c \
- libelf/libelf_next_prime.c \
- libelf/nlist.c
-
-LOCAL_SRC_FILES := $(LIBELF_SRC_FILES)
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/lib $(LOCAL_PATH)/libelf
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/host-$(HOST_OS)-fixup
-
-LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE
-
-# to suppress the "pointer of type ‘void *’ used in arithmetic" warning
-LOCAL_CFLAGS += -Wno-pointer-arith
-
-ifeq ($(HOST_OS),darwin)
- LOCAL_CFLAGS += -fnested-functions
-endif
-
-# to fix machine-dependent issues
-LOCAL_CFLAGS += -include $(LOCAL_PATH)/host-$(HOST_OS)-fixup/AndroidFixup.h
-
-LOCAL_MODULE := libelf
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-endif #cur_platform
+include $(call all-subdir-makefiles)
diff --git a/android.patch b/android.patch
index 40219013..7d50f4f4 100644
--- a/android.patch
+++ b/android.patch
@@ -1,6 +1,6 @@
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdw/dwarf_begin.c ./libdw/dwarf_begin.c
---- /home/bccheng/local/elfutils-0.138/libdw/dwarf_begin.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libdw/dwarf_begin.c 2012-03-07 15:56:49.000000000 -0800
+diff -r -u -d /local/elfutils-0.138/libdw/dwarf_begin.c ./libdw/dwarf_begin.c
+--- /local/elfutils-0.138/libdw/dwarf_begin.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdw/dwarf_begin.c 2012-03-09 10:19:33.000000000 -0800
@@ -94,7 +94,9 @@
/* Get an ELF descriptor. */
elf = elf_begin (fd, elfcmd, NULL);
@@ -22,9 +22,9 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdw/dwarf_begin.c ./libdw/dwa
}
else
{
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdw/dwarf_getpubnames.c ./libdw/dwarf_getpubnames.c
---- /home/bccheng/local/elfutils-0.138/libdw/dwarf_getpubnames.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libdw/dwarf_getpubnames.c 2012-03-07 15:56:49.000000000 -0800
+diff -r -u -d /local/elfutils-0.138/libdw/dwarf_getpubnames.c ./libdw/dwarf_getpubnames.c
+--- /local/elfutils-0.138/libdw/dwarf_getpubnames.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdw/dwarf_getpubnames.c 2012-03-12 11:09:29.000000000 -0700
@@ -60,6 +60,9 @@
#include <libdwP.h>
#include <dwarf.h>
@@ -35,23 +35,20 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdw/dwarf_getpubnames.c ./lib
static int
get_offsets (Dwarf *dbg)
-@@ -235,7 +238,13 @@
- gl.die_offset += dbg->pubnames_sets[cnt].cu_offset;
+diff -r -u -d /local/elfutils-0.138/libdw/dwarf_getsrc_file.c ./libdw/dwarf_getsrc_file.c
+--- /local/elfutils-0.138/libdw/dwarf_getsrc_file.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdw/dwarf_getsrc_file.c 2012-03-12 12:42:46.000000000 -0700
+@@ -59,7 +59,6 @@
- gl.name = (char *) readp;
-+ /* ANDROID_CHANGE_BEGIN */
-+#ifdef __BIONIC__
-+ readp = gl.name + strlen(gl.name) + 1;
-+#else
- readp = (unsigned char *) rawmemchr (gl.name, '\0') + 1;
-+#endif
-+ /* ANDROID_CHANGE_END */
+ #include "libdwP.h"
- /* We found name and DIE offset. Report it. */
- if (callback (dbg, &gl, arg) != DWARF_CB_OK)
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdw/libdw_alloc.c ./libdw/libdw_alloc.c
---- /home/bccheng/local/elfutils-0.138/libdw/libdw_alloc.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libdw/libdw_alloc.c 2012-03-07 15:56:49.000000000 -0800
+-
+ int
+ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column,
+ Dwarf_Line ***srcsp, size_t *nsrcs)
+diff -r -u -d /local/elfutils-0.138/libdw/libdw_alloc.c ./libdw/libdw_alloc.c
+--- /local/elfutils-0.138/libdw/libdw_alloc.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdw/libdw_alloc.c 2012-03-09 10:19:35.000000000 -0800
@@ -58,6 +58,9 @@
#include <sys/param.h>
#include "libdwP.h"
@@ -62,20 +59,18 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdw/libdw_alloc.c ./libdw/lib
void *
__libdw_allocate (Dwarf *dbg, size_t minsize, size_t align)
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.c ./libdwfl/dwfl_build_id_find_elf.c
---- /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libdwfl/dwfl_build_id_find_elf.c 2012-03-07 15:56:49.000000000 -0800
-@@ -52,6 +52,9 @@
+diff -r -u -d /local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.c ./libdwfl/dwfl_build_id_find_elf.c
+--- /local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdwfl/dwfl_build_id_find_elf.c 2012-03-12 12:23:29.000000000 -0700
+@@ -52,7 +52,6 @@
#include <fcntl.h>
#include <unistd.h>
-+/* ANDROID_CHANGE_BEGIN */
-+#include <AndroidFixup.h>
-+/* ANDROID_CHANGE_END */
-
+-
int
internal_function
-@@ -84,8 +87,16 @@
+ __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name)
+@@ -84,8 +83,16 @@
".debug");
const Dwfl_Callbacks *const cb = mod->dwfl->callbacks;
@@ -92,7 +87,7 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.
int fd = -1;
char *dir;
-@@ -103,7 +114,6 @@
+@@ -103,7 +110,6 @@
if (unlikely (name == NULL))
break;
memcpy (mempcpy (name, dir, dirlen), id_name, sizeof id_name);
@@ -100,7 +95,7 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.
fd = TEMP_FAILURE_RETRY (open64 (name, O_RDONLY));
if (fd >= 0)
{
-@@ -119,6 +129,12 @@
+@@ -119,6 +125,12 @@
free (name);
}
@@ -113,10 +108,28 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_build_id_find_elf.
/* If we simply found nothing, clear errno. If we had some other error
with the file, report that. Possibly this should treat other errors
like ENOENT too. But ignoring all errors could mask some that should
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_build_id.c ./libdwfl/dwfl_module_build_id.c
---- /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_build_id.c 2008-12-30 21:48:23.000000000 -0800
-+++ ./libdwfl/dwfl_module_build_id.c 2012-03-07 15:56:49.000000000 -0800
-@@ -139,9 +139,16 @@
+diff -r -u -d /local/elfutils-0.138/libdwfl/dwfl_error.c ./libdwfl/dwfl_error.c
+--- /local/elfutils-0.138/libdwfl/dwfl_error.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdwfl/dwfl_error.c 2012-03-12 12:39:16.000000000 -0700
+@@ -218,7 +218,14 @@
+ switch (error &~ 0xffff)
+ {
+ case OTHER_ERROR (ERRNO):
++ /* ANDROID_CHANGE_BEGIN */
++#ifdef __BIONIC__
++ strerror_r (error & 0xffff, "bad", 0);
++ return NULL;
++#else
+ return strerror_r (error & 0xffff, "bad", 0);
++#endif
++ /* ANDROID_CHANGE_END */
+ case OTHER_ERROR (LIBELF):
+ return elf_errmsg (error & 0xffff);
+ case OTHER_ERROR (LIBDW):
+diff -r -u -d /local/elfutils-0.138/libdwfl/dwfl_module_build_id.c ./libdwfl/dwfl_module_build_id.c
+--- /local/elfutils-0.138/libdwfl/dwfl_module_build_id.c 2008-12-30 21:48:23.000000000 -0800
++++ ./libdwfl/dwfl_module_build_id.c 2012-03-12 12:40:16.000000000 -0700
+@@ -139,9 +139,17 @@
return result;
}
@@ -126,6 +139,7 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_build_id.c
__dwfl_module_build_id (Dwfl_Module *mod,
const unsigned char **bits, GElf_Addr *vaddr)
+#else
++int
+dwfl_module_build_id (Dwfl_Module *mod,
+ const unsigned char **bits, GElf_Addr *vaddr)
+#endif
@@ -133,7 +147,7 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_build_id.c
{
if (mod == NULL)
return -1;
-@@ -164,6 +171,9 @@
+@@ -164,6 +172,9 @@
*vaddr = mod->build_id_vaddr;
return mod->build_id_len;
}
@@ -143,39 +157,46 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_build_id.c
extern __typeof__ (dwfl_module_build_id) INTUSE(dwfl_module_build_id)
__attribute__ ((alias ("__dwfl_module_build_id")));
asm (".symver "
-@@ -180,3 +190,5 @@
+@@ -180,3 +191,5 @@
}
asm (".symver "
"_BUG_COMPAT_dwfl_module_build_id, dwfl_module_build_id@ELFUTILS_0.130");
+#endif
+/* ANDROID_CHANGE_END */
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_getdwarf.c ./libdwfl/dwfl_module_getdwarf.c
---- /home/bccheng/local/elfutils-0.138/libdwfl/dwfl_module_getdwarf.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libdwfl/dwfl_module_getdwarf.c 2012-03-07 15:56:49.000000000 -0800
-@@ -53,6 +53,9 @@
+diff -r -u -d /local/elfutils-0.138/libdwfl/dwfl_module_getdwarf.c ./libdwfl/dwfl_module_getdwarf.c
+--- /local/elfutils-0.138/libdwfl/dwfl_module_getdwarf.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdwfl/dwfl_module_getdwarf.c 2012-03-12 12:24:14.000000000 -0700
+@@ -53,7 +53,6 @@
#include <unistd.h>
#include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
-+/* ANDROID_CHANGE_BEGIN */
-+#include <AndroidFixup.h>
-+/* ANDROID_CHANGE_END */
-
+-
/* Open libelf FILE->fd and compute the load base of ELF as loaded in MOD.
When we return success, FILE->elf and FILE->bias are set up. */
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/find-debuginfo.c ./libdwfl/find-debuginfo.c
---- /home/bccheng/local/elfutils-0.138/libdwfl/find-debuginfo.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libdwfl/find-debuginfo.c 2012-03-07 15:56:49.000000000 -0800
-@@ -53,6 +53,9 @@
+ static inline Dwfl_Error
+diff -r -u -d /local/elfutils-0.138/libdwfl/dwfl_module_getsrc_file.c ./libdwfl/dwfl_module_getsrc_file.c
+--- /local/elfutils-0.138/libdwfl/dwfl_module_getsrc_file.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdwfl/dwfl_module_getsrc_file.c 2012-03-12 12:42:55.000000000 -0700
+@@ -50,7 +50,6 @@
+ #include "libdwflP.h"
+ #include "../libdw/libdwP.h"
+
+-
+ int
+ dwfl_module_getsrc_file (Dwfl_Module *mod,
+ const char *fname, int lineno, int column,
+diff -r -u -d /local/elfutils-0.138/libdwfl/find-debuginfo.c ./libdwfl/find-debuginfo.c
+--- /local/elfutils-0.138/libdwfl/find-debuginfo.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libdwfl/find-debuginfo.c 2012-03-12 12:24:39.000000000 -0700
+@@ -53,7 +53,6 @@
#include <unistd.h>
#include "system.h"
-+/* ANDROID_CHANGE_BEGIN */
-+#include <AndroidFixup.h>
-+/* ANDROID_CHANGE_END */
-
+-
/* Try to open64 [DIR/][SUBDIR/]DEBUGLINK, return file descriptor or -1.
On success, *DEBUGINFO_FILE_NAME has the malloc'd name of the open file. */
-@@ -145,8 +148,15 @@
+ static int
+@@ -145,8 +144,15 @@
indicated by the debug directory path setting. */
const Dwfl_Callbacks *const cb = mod->dwfl->callbacks;
@@ -191,7 +212,7 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/find-debuginfo.c ./libd
/* A leading - or + in the whole path sets whether to check file CRCs. */
bool defcheck = true;
-@@ -156,8 +166,15 @@
+@@ -156,8 +162,15 @@
++path;
}
@@ -207,7 +228,7 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/find-debuginfo.c ./libd
char *p;
while ((p = strsep (&path, ":")) != NULL)
{
-@@ -201,17 +218,36 @@
+@@ -201,17 +214,36 @@
case ENOTDIR:
continue;
default:
@@ -244,23 +265,41 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/find-debuginfo.c ./libd
/* No dice. */
errno = 0;
return -1;
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libdwfl/offline.c ./libdwfl/offline.c
---- /home/bccheng/local/elfutils-0.138/libdwfl/offline.c 2008-12-17 16:29:37.000000000 -0800
-+++ ./libdwfl/offline.c 2012-03-07 15:56:49.000000000 -0800
-@@ -51,6 +51,10 @@
- #include <fcntl.h>
- #include <unistd.h>
-
+diff -r -u -d /local/elfutils-0.138/libebl/eblopenbackend.c ./libebl/eblopenbackend.c
+--- /local/elfutils-0.138/libebl/eblopenbackend.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libebl/eblopenbackend.c 2012-03-16 16:55:06.000000000 -0700
+@@ -196,8 +196,15 @@
+ uint32_t descsz, const char *desc);
+ static bool default_debugscn_p (const char *name);
+ static bool default_copy_reloc_p (int reloc);
+/* ANDROID_CHANGE_BEGIN */
-+#include <AndroidFixup.h>
++#ifndef __APPLE__
+ static bool default_none_reloc_p (int reloc);
+ static bool default_relative_reloc_p (int reloc);
++#else
++#define default_none_reloc_p default_copy_reloc_p
++#define default_relative_reloc_p default_copy_reloc_p
++#endif
+/* ANDROID_CHANGE_END */
-+
- /* Since dwfl_report_elf lays out the sections already, this will only be
- called when the section headers of the debuginfo file are being
- consulted instead, or for the section placed at 0. With binutils
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libebl/libeblP.h ./libebl/libeblP.h
---- /home/bccheng/local/elfutils-0.138/libebl/libeblP.h 2008-12-10 20:33:30.000000000 -0800
-+++ ./libebl/libeblP.h 2012-03-07 15:56:49.000000000 -0800
+ static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
+ const GElf_Sym *sym,
+ const char *name,
+@@ -677,8 +684,12 @@
+ {
+ return false;
+ }
++/* ANDROID_CHANGE_BEGIN */
++#ifndef __APPLE__
+ strong_alias (default_copy_reloc_p, default_none_reloc_p)
+ strong_alias (default_copy_reloc_p, default_relative_reloc_p)
++#endif
++/* ANDROID_CHANGE_END */
+
+ static bool
+ default_check_special_symbol (Elf *elf __attribute__ ((unused)),
+diff -r -u -d /local/elfutils-0.138/libebl/libeblP.h ./libebl/libeblP.h
+--- /local/elfutils-0.138/libebl/libeblP.h 2008-12-10 20:33:30.000000000 -0800
++++ ./libebl/libeblP.h 2012-03-09 10:19:37.000000000 -0800
@@ -55,7 +55,6 @@
#include <libebl.h>
#include <libintl.h>
@@ -269,9 +308,9 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libebl/libeblP.h ./libebl/libeb
/* Backend handle. */
struct ebl
{
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/elf32_fsize.c ./libelf/elf32_fsize.c
---- /home/bccheng/local/elfutils-0.138/libelf/elf32_fsize.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libelf/elf32_fsize.c 2012-03-08 15:00:38.000000000 -0800
+diff -r -u -d /local/elfutils-0.138/libelf/elf32_fsize.c ./libelf/elf32_fsize.c
+--- /local/elfutils-0.138/libelf/elf32_fsize.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libelf/elf32_fsize.c 2012-03-09 10:19:38.000000000 -0800
@@ -88,5 +88,9 @@
* __libelf_type_sizes[0][ELFW(ELFCLASS,LIBELFBITS) - 1][type]);
#endif
@@ -282,9 +321,9 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/elf32_fsize.c ./libelf/e
local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS, msize))
+#endif
+/* ANDROID_CHANGE_END */
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/elf_begin.c ./libelf/elf_begin.c
---- /home/bccheng/local/elfutils-0.138/libelf/elf_begin.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libelf/elf_begin.c 2012-03-08 15:34:30.000000000 -0800
+diff -r -u -d /local/elfutils-0.138/libelf/elf_begin.c ./libelf/elf_begin.c
+--- /local/elfutils-0.138/libelf/elf_begin.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libelf/elf_begin.c 2012-03-09 10:19:38.000000000 -0800
@@ -68,7 +68,6 @@
#include "libelfP.h"
#include "common.h"
@@ -293,9 +332,42 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/elf_begin.c ./libelf/elf
/* Create descriptor for archive in memory. */
static inline Elf *
file_read_ar (int fildes, void *map_address, off_t offset, size_t maxsize,
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/elf.h ./libelf/elf.h
---- /home/bccheng/local/elfutils-0.138/libelf/elf.h 2008-12-10 20:33:30.000000000 -0800
-+++ ./libelf/elf.h 2012-03-08 15:06:31.000000000 -0800
+diff -r -u -d /local/elfutils-0.138/libelf/elf_getdata_rawchunk.c ./libelf/elf_getdata_rawchunk.c
+--- /local/elfutils-0.138/libelf/elf_getdata_rawchunk.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libelf/elf_getdata_rawchunk.c 2012-03-15 11:14:32.000000000 -0700
+@@ -64,7 +64,13 @@
+ Elf_Data *
+ elf_getdata_rawchunk (elf, offset, size, type)
+ Elf *elf;
++ /* ANDROID_CHANGE_BEGIN */
++#if 0
+ off64_t offset;
++#else
++ off_t offset;
++#endif
++ /* ANDROID_CHANGE_END */
+ size_t size;
+ Elf_Type type;
+ {
+@@ -78,8 +84,15 @@
+ return NULL;
+ }
+
++ /* ANDROID_CHANGE_BEGIN */
++#if 0
+ if (unlikely (size > elf->maximum_size
+ || (off64_t) (elf->maximum_size - size) < offset))
++#else
++ if (unlikely (size > elf->maximum_size
++ || (off_t) (elf->maximum_size - size) < offset))
++#endif
++ /* ANDROID_CHANGE_END */
+ {
+ /* Invalid request. */
+ __libelf_seterrno (ELF_E_INVALID_OP);
+diff -r -u -d /local/elfutils-0.138/libelf/elf.h ./libelf/elf.h
+--- /local/elfutils-0.138/libelf/elf.h 2008-12-10 20:33:30.000000000 -0800
++++ ./libelf/elf.h 2012-03-09 10:19:38.000000000 -0800
@@ -21,7 +21,15 @@
#ifndef _ELF_H
#define _ELF_H 1
@@ -312,9 +384,9 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/elf.h ./libelf/elf.h
__BEGIN_DECLS
-diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/gelf_xlate.c ./libelf/gelf_xlate.c
---- /home/bccheng/local/elfutils-0.138/libelf/gelf_xlate.c 2008-12-10 20:33:30.000000000 -0800
-+++ ./libelf/gelf_xlate.c 2012-03-08 15:00:38.000000000 -0800
+diff -r -u -d /local/elfutils-0.138/libelf/gelf_xlate.c ./libelf/gelf_xlate.c
+--- /local/elfutils-0.138/libelf/gelf_xlate.c 2008-12-10 20:33:30.000000000 -0800
++++ ./libelf/gelf_xlate.c 2012-03-09 10:19:39.000000000 -0800
@@ -229,7 +229,11 @@
}
}
@@ -327,3 +399,93 @@ diff -r -u -d /home/bccheng/local/elfutils-0.138/libelf/gelf_xlate.c ./libelf/ge
strong_alias (__elf_xfctstom, __elf_xfctstof)
+#endif
+/* ANDROID_CHANGE_END */
+diff -r -u -d /local/elfutils-0.138/libelf/libelf.h ./libelf/libelf.h
+--- /local/elfutils-0.138/libelf/libelf.h 2008-12-17 16:29:37.000000000 -0800
++++ ./libelf/libelf.h 2012-03-15 11:07:48.000000000 -0700
+@@ -95,7 +95,13 @@
+ Elf_Type d_type; /* Type of this piece of data. */
+ unsigned int d_version; /* ELF version. */
+ size_t d_size; /* Size in bytes. */
++ /* ANDROID_CHANGE_BEGIN */
++#if 0
+ loff_t d_off; /* Offset into section. */
++#else
++ off_t d_off; /* Offset into section. */
++#endif
++ /* ANDROID_CHANGE_END */
+ size_t d_align; /* Alignment in section. */
+ } Elf_Data;
+
+@@ -157,7 +163,13 @@
+ uid_t ar_uid; /* User ID. */
+ gid_t ar_gid; /* Group ID. */
+ mode_t ar_mode; /* File mode. */
++ /* ANDROID_CHANGE_BEGIN */
++#if 0
+ loff_t ar_size; /* File size. */
++#else
++ off_t ar_size; /* File size. */
++#endif
++ /* ANDROID_CHANGE_END */
+ char *ar_rawname; /* Original name of archive member. */
+ } Elf_Arhdr;
+
+@@ -198,13 +210,25 @@
+ extern int elf_end (Elf *__elf);
+
+ /* Update ELF descriptor and write file to disk. */
+-extern loff_t elf_update (Elf *__elf, Elf_Cmd __cmd);
++/* ANDROID_CHANGE_BEGIN */
++#if 0
++extern off_t elf_update (Elf *__elf, Elf_Cmd __cmd);
++#else
++#endif
++/* ANDROID_CHANGE_END */
++
+
+ /* Determine what kind of file is associated with ELF. */
+ extern Elf_Kind elf_kind (Elf *__elf) __attribute__ ((__pure__));
+
+ /* Get the base offset for an object file. */
++/* ANDROID_CHANGE_BEGIN */
++#if 0
+ extern loff_t elf_getbase (Elf *__elf);
++#else
++extern off_t elf_getbase (Elf *__elf);
++#endif
++/* ANDROID_CHANGE_END */
+
+
+ /* Retrieve file identification data. */
+@@ -305,9 +329,17 @@
+ /* Get data translated from a chunk of the file contents as section data
+ would be for TYPE. The resulting Elf_Data pointer is valid until
+ elf_end (ELF) is called. */
++/* ANDROID_CHANGE_BEGIN */
++#if 0
+ extern Elf_Data *elf_getdata_rawchunk (Elf *__elf,
+ loff_t __offset, size_t __size,
+ Elf_Type __type);
++#else
++extern Elf_Data *elf_getdata_rawchunk (Elf *__elf,
++ off_t __offset, size_t __size,
++ Elf_Type __type);
++#endif
++/* ANDROID_CHANGE_END */
+
+
+ /* Return pointer to string at OFFSET in section INDEX. */
+@@ -318,7 +350,13 @@
+ extern Elf_Arhdr *elf_getarhdr (Elf *__elf);
+
+ /* Return offset in archive for current file ELF. */
++/* ANDROID_CHANGE_BEGIN */
++#if 0
+ extern loff_t elf_getaroff (Elf *__elf);
++#else
++extern off_t elf_getaroff (Elf *__elf);
++#endif
++/* ANDROID_CHANGE_END */
+
+ /* Select archive element at OFFSET. */
+ extern size_t elf_rand (Elf *__elf, size_t __offset);
diff --git a/bionic-fixup/AndroidFixup.h b/bionic-fixup/AndroidFixup.h
new file mode 100644
index 00000000..e96d57ed
--- /dev/null
+++ b/bionic-fixup/AndroidFixup.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_FIXUP_H
+#define ANDROID_FIXUP_H
+
+#include <stdio.h>
+#include <libgen.h> // for basename
+
+//#define _OFF_T_DEFINED_
+
+//#define off_t loff_t
+
+#ifndef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif
+
+#ifndef powerof2
+#define powerof2(x) (((x - 1) & (x)) == 0)
+#endif
+
+/* workaround for canonicalize_file_name */
+#define canonicalize_file_name(path) realpath(path, NULL)
+
+/* workaround for open64 */
+#define open64(path, flags) open(path, ((flags) | O_LARGEFILE))
+
+/* no internalization */
+#define gettext(x) (x)
+
+/* _mempcpy and mempcpy */
+#ifndef __mempcpy
+#define __mempcpy(dest, src, n) mempcpy(dest, src, n)
+#endif
+
+#ifndef mempcpy
+#include <string.h>
+
+static inline void *mempcpy(void *dest, const void *src, size_t n)
+{
+ char *ptr = memcpy(dest, src, n);
+ return ptr + n;
+}
+#endif
+
+/* rawmemchr */
+static inline void *rawmemchr(const void *s, int c)
+{
+ const unsigned char *ptr = s;
+ while (1) {
+ if (*ptr == c) return (void *) ptr;
+ ptr++;
+ }
+}
+
+/* workaround for stpcpy */
+static inline char *stpcpy(char *dst, const char *src)
+{
+ while (*src) {
+ *dst++ = *src++;
+ }
+ return dst;
+}
+
+/* forward declarations */
+char * dgettext (const char * domainname, const char * msgid);
+
+ssize_t getline(char **lineptr, size_t *n, FILE *stream);
+
+#endif /* ANDROID_FIXUP_H */
diff --git a/bionic-fixup/error.h b/bionic-fixup/error.h
new file mode 100644
index 00000000..1204eff9
--- /dev/null
+++ b/bionic-fixup/error.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ELFUTILS_ERROR_H
+#define ELFUTILS_ERROR_H
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static inline void __attribute__((noreturn))
+error(int status, int errnum, const char *fmt, ...)
+{
+ va_list lst;
+ va_start(lst, fmt);
+ vfprintf(stderr, fmt, lst);
+ fprintf(stderr, "error %d: %s\n", errnum, strerror(errno));
+ va_end(lst);
+ exit(status);
+}
+
+#endif /* ELFUTILS_ERROR_H */
diff --git a/bionic-fixup/getline.c b/bionic-fixup/getline.c
new file mode 100644
index 00000000..041a5ed9
--- /dev/null
+++ b/bionic-fixup/getline.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+ssize_t getline(char **lineptr, size_t *n, FILE *stream)
+{
+ char *ptr;
+
+ ptr = fgetln(stream, n);
+
+ if (ptr == NULL) {
+ return -1;
+ }
+
+ /* Free the original ptr */
+ if (*lineptr != NULL) free(*lineptr);
+
+ /* Add one more space for '\0' */
+ size_t len = n[0] + 1;
+
+ /* Update the length */
+ n[0] = len;
+
+ /* Allocate a new buffer */
+ *lineptr = malloc(len);
+
+ /* Copy over the string */
+ memcpy(*lineptr, ptr, len-1);
+
+ /* Write the NULL character */
+ (*lineptr)[len-1] = '\0';
+
+ /* Return the length of the new buffer */
+ return len;
+}
diff --git a/bionic-fixup/libintl.h b/bionic-fixup/libintl.h
new file mode 100644
index 00000000..da26bfac
--- /dev/null
+++ b/bionic-fixup/libintl.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ELFUTILS_LIBINTL_H
+#define ELFUTILS_LIBINTL_H
+
+/* intentionally blank */
+
+#endif /* ELFUTILS_LIBINTL_H */
diff --git a/bionic-fixup/stdio_ext.h b/bionic-fixup/stdio_ext.h
new file mode 100644
index 00000000..3acd20ac
--- /dev/null
+++ b/bionic-fixup/stdio_ext.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ELFUTILS_BIONIC_FIXUP_STDIO_EXT_H
+#define ELFUTILS_BIONIC_FIXUP_STDIO_EXT_H
+
+/* intentionally blank */
+
+#endif /* ELFUTILS_BIONIC_FIXUP_STDIO_EXT_H */
diff --git a/host-darwin-fixup/AndroidFixup.h b/host-darwin-fixup/AndroidFixup.h
index f7afcd41..1342843f 100644
--- a/host-darwin-fixup/AndroidFixup.h
+++ b/host-darwin-fixup/AndroidFixup.h
@@ -1,8 +1,24 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef ANDROID_FIXUP_H
#define ANDROID_FIXUP_H
-#define off_t loff_t
-#define off64_t loff_t
+#define loff_t off_t
+#define off64_t off_t
#include <string.h>
#include <stdarg.h>
diff --git a/host-darwin-fixup/byteswap.h b/host-darwin-fixup/byteswap.h
index db5192d9..6b3d212a 100644
--- a/host-darwin-fixup/byteswap.h
+++ b/host-darwin-fixup/byteswap.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef ELFUTILS_BYTESWAP_H
#define ELFUTILS_BYTESWAP_H
diff --git a/host-darwin-fixup/endian.h b/host-darwin-fixup/endian.h
index 004acdaa..285e1964 100644
--- a/host-darwin-fixup/endian.h
+++ b/host-darwin-fixup/endian.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef ELFUTILS_ENDIAN_H
#define ELFUTILS_ENDIAN_H
diff --git a/host-darwin-fixup/error.h b/host-darwin-fixup/error.h
new file mode 100644
index 00000000..4b892571
--- /dev/null
+++ b/host-darwin-fixup/error.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ELFUTILS_ERROR_H
+#define ELFUTILS_ERROR_H
+
+/* intentionally blank */
+
+#endif /* ELFUTILS_ERROR_H */
diff --git a/host-darwin-fixup/libintl.h b/host-darwin-fixup/libintl.h
index 56af5c20..da26bfac 100644
--- a/host-darwin-fixup/libintl.h
+++ b/host-darwin-fixup/libintl.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef ELFUTILS_LIBINTL_H
#define ELFUTILS_LIBINTL_H
diff --git a/host-linux-fixup/AndroidFixup.h b/host-linux-fixup/AndroidFixup.h
index e8531630..909867cc 100644
--- a/host-linux-fixup/AndroidFixup.h
+++ b/host-linux-fixup/AndroidFixup.h
@@ -1,4 +1,22 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#ifndef ANDROID_FIXUP_H
#define ANDROID_FIXUP_H
+/* intentionally blank */
+
#endif /* ANDROID_FIXUP_H */
diff --git a/libdw/Android.mk b/libdw/Android.mk
new file mode 100755
index 00000000..44f0223a
--- /dev/null
+++ b/libdw/Android.mk
@@ -0,0 +1,176 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+supported_platforms := linux-x86 darwin-x86
+cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
+
+ifdef cur_platform
+
+#
+# host libdw
+#
+
+include $(CLEAR_VARS)
+
+LIBDW_SRC_FILES := \
+ dwarf_abbrevhaschildren.c \
+ dwarf_abbrev_hash.c \
+ dwarf_addrdie.c \
+ dwarf_arrayorder.c \
+ dwarf_attr.c \
+ dwarf_attr_integrate.c \
+ dwarf_begin.c \
+ dwarf_begin_elf.c \
+ dwarf_bitoffset.c \
+ dwarf_bitsize.c \
+ dwarf_bytesize.c \
+ dwarf_child.c \
+ dwarf_cuoffset.c \
+ dwarf_decl_column.c \
+ dwarf_decl_file.c \
+ dwarf_decl_line.c \
+ dwarf_diecu.c \
+ dwarf_diename.c \
+ dwarf_dieoffset.c \
+ dwarf_end.c \
+ dwarf_entry_breakpoints.c \
+ dwarf_entrypc.c \
+ dwarf_error.c \
+ dwarf_filesrc.c \
+ dwarf_formaddr.c \
+ dwarf_formblock.c \
+ dwarf_formflag.c \
+ dwarf_formref.c \
+ dwarf_formref_die.c \
+ dwarf_formsdata.c \
+ dwarf_formstring.c \
+ dwarf_formudata.c \
+ dwarf_func_inline.c \
+ dwarf_getabbrevattr.c \
+ dwarf_getabbrev.c \
+ dwarf_getabbrevcode.c \
+ dwarf_getabbrevtag.c \
+ dwarf_getarange_addr.c \
+ dwarf_getarangeinfo.c \
+ dwarf_getaranges.c \
+ dwarf_getattrcnt.c \
+ dwarf_getattrs.c \
+ dwarf_getelf.c \
+ dwarf_getfuncs.c \
+ dwarf_getlocation.c \
+ dwarf_getmacros.c \
+ dwarf_getpubnames.c \
+ dwarf_getscopes.c \
+ dwarf_getscopes_die.c \
+ dwarf_getscopevar.c \
+ dwarf_getsrc_die.c \
+ dwarf_getsrcdirs.c \
+ dwarf_getsrc_file.c \
+ dwarf_getsrcfiles.c \
+ dwarf_getsrclines.c \
+ dwarf_getstring.c \
+ dwarf_hasattr.c \
+ dwarf_hasattr_integrate.c \
+ dwarf_haschildren.c \
+ dwarf_hasform.c \
+ dwarf_haspc.c \
+ dwarf_highpc.c \
+ dwarf_lineaddr.c \
+ dwarf_linebeginstatement.c \
+ dwarf_lineblock.c \
+ dwarf_linecol.c \
+ dwarf_lineendsequence.c \
+ dwarf_lineepiloguebegin.c \
+ dwarf_lineno.c \
+ dwarf_lineprologueend.c \
+ dwarf_linesrc.c \
+ dwarf_lowpc.c \
+ dwarf_macro_opcode.c \
+ dwarf_macro_param1.c \
+ dwarf_macro_param2.c \
+ dwarf_nextcu.c \
+ dwarf_offabbrev.c \
+ dwarf_offdie.c \
+ dwarf_onearange.c \
+ dwarf_onesrcline.c \
+ dwarf_ranges.c \
+ dwarf_siblingof.c \
+ dwarf_srclang.c \
+ dwarf_tag.c \
+ dwarf_whatattr.c \
+ dwarf_whatform.c \
+ libdw_alloc.c \
+ libdw_findcu.c \
+ libdw_form.c \
+ libdw_visit_scopes.c \
+ memory-access.c
+
+LOCAL_SRC_FILES := $(LIBDW_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libdw \
+ $(LOCAL_PATH)/../libelf
+
+ifeq ($(HOST_OS),darwin)
+ LOCAL_CFLAGS += -fnested-functions
+endif
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../host-$(HOST_OS)-fixup
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE -DIS_LIBDW
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE:= libdw
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+#
+# target libdw
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(LIBDW_SRC_FILES)
+
+# missing utility functions in bionic
+LOCAL_SRC_FILES += \
+ ../bionic-fixup/getline.c \
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libdw \
+ $(LOCAL_PATH)/../libelf
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../bionic-fixup
+
+LOCAL_CFLAGS += -include $(LOCAL_PATH)/../bionic-fixup/AndroidFixup.h
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -DIS_LIBDW -Werror
+
+# to suppress the "pointer of type ‘void *’ used in arithmetic" warning
+LOCAL_CFLAGS += -Wno-pointer-arith
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE:= libdw
+
+include $(BUILD_STATIC_LIBRARY)
+
+endif #cur_platform
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c
index 3897c259..e7872955 100644
--- a/libdw/dwarf_getpubnames.c
+++ b/libdw/dwarf_getpubnames.c
@@ -238,13 +238,7 @@ dwarf_getpubnames (dbg, callback, arg, offset)
gl.die_offset += dbg->pubnames_sets[cnt].cu_offset;
gl.name = (char *) readp;
- /* ANDROID_CHANGE_BEGIN */
-#ifdef __BIONIC__
- readp = gl.name + strlen(gl.name) + 1;
-#else
readp = (unsigned char *) rawmemchr (gl.name, '\0') + 1;
-#endif
- /* ANDROID_CHANGE_END */
/* We found name and DIE offset. Report it. */
if (callback (dbg, &gl, arg) != DWARF_CB_OK)
diff --git a/libdw/dwarf_getsrc_file.c b/libdw/dwarf_getsrc_file.c
index 91abbaeb..2c4fc768 100644
--- a/libdw/dwarf_getsrc_file.c
+++ b/libdw/dwarf_getsrc_file.c
@@ -59,7 +59,6 @@
#include "libdwP.h"
-
int
dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column,
Dwarf_Line ***srcsp, size_t *nsrcs)
diff --git a/libdwfl/Android.mk b/libdwfl/Android.mk
new file mode 100755
index 00000000..71a7ddbe
--- /dev/null
+++ b/libdwfl/Android.mk
@@ -0,0 +1,104 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+supported_platforms := linux-x86 darwin-x86
+cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
+
+ifdef cur_platform
+
+#
+# host libdwfl
+#
+
+include $(CLEAR_VARS)
+
+LIBDWFL_SRC_FILES := \
+ dwfl_begin.c \
+ dwfl_build_id_find_elf.c \
+ dwfl_build_id_find_debuginfo.c \
+ libdwfl_crc32.c \
+ libdwfl_crc32_file.c \
+ dwfl_end.c \
+ dwfl_error.c \
+ dwfl_module.c \
+ dwfl_module_addrdie.c \
+ dwfl_module_build_id.c \
+ dwfl_module_getdwarf.c \
+ dwfl_report_elf.c \
+ find-debuginfo.c \
+ offline.c \
+ relocate.c
+
+LOCAL_SRC_FILES := $(LIBDWFL_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libdwfl \
+ $(LOCAL_PATH)/../libebl \
+ $(LOCAL_PATH)/../libdw \
+ $(LOCAL_PATH)/../libelf
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../host-$(HOST_OS)-fixup
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE
+
+# to suppress the "pointer of type ‘void *’ used in arithmetic" warning
+LOCAL_CFLAGS += -Wno-pointer-arith
+
+ifeq ($(HOST_OS),darwin)
+ LOCAL_CFLAGS += -fnested-functions
+endif
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE:= libdwfl
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+#
+# target libdwfl
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(LIBDWFL_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libdwfl \
+ $(LOCAL_PATH)/../libebl \
+ $(LOCAL_PATH)/../libdw \
+ $(LOCAL_PATH)/../libelf
+
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../bionic-fixup
+
+LOCAL_CFLAGS += -include $(LOCAL_PATH)/../bionic-fixup/AndroidFixup.h
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -Werror
+
+# to suppress the "pointer of type ‘void *’ used in arithmetic" warning
+LOCAL_CFLAGS += -Wno-pointer-arith
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE:= libdwfl
+
+include $(BUILD_STATIC_LIBRARY)
+
+endif #cur_platform
diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
index 88aa8211..21c77190 100644
--- a/libdwfl/dwfl_build_id_find_elf.c
+++ b/libdwfl/dwfl_build_id_find_elf.c
@@ -52,10 +52,6 @@
#include <fcntl.h>
#include <unistd.h>
-/* ANDROID_CHANGE_BEGIN */
-#include <AndroidFixup.h>
-/* ANDROID_CHANGE_END */
-
int
internal_function
__libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name)
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index 414fbaf4..f011be1a 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -218,7 +218,14 @@ dwfl_errmsg (error)
switch (error &~ 0xffff)
{
case OTHER_ERROR (ERRNO):
+ /* ANDROID_CHANGE_BEGIN */
+#ifdef __BIONIC__
+ strerror_r (error & 0xffff, "bad", 0);
+ return NULL;
+#else
return strerror_r (error & 0xffff, "bad", 0);
+#endif
+ /* ANDROID_CHANGE_END */
case OTHER_ERROR (LIBELF):
return elf_errmsg (error & 0xffff);
case OTHER_ERROR (LIBDW):
diff --git a/libdwfl/dwfl_module_build_id.c b/libdwfl/dwfl_module_build_id.c
index 17d8f9f7..3470678f 100644
--- a/libdwfl/dwfl_module_build_id.c
+++ b/libdwfl/dwfl_module_build_id.c
@@ -145,6 +145,7 @@ int
__dwfl_module_build_id (Dwfl_Module *mod,
const unsigned char **bits, GElf_Addr *vaddr)
#else
+int
dwfl_module_build_id (Dwfl_Module *mod,
const unsigned char **bits, GElf_Addr *vaddr)
#endif
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index 9206dbb4..51f00a01 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -53,10 +53,6 @@
#include <unistd.h>
#include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
-/* ANDROID_CHANGE_BEGIN */
-#include <AndroidFixup.h>
-/* ANDROID_CHANGE_END */
-
/* Open libelf FILE->fd and compute the load base of ELF as loaded in MOD.
When we return success, FILE->elf and FILE->bias are set up. */
static inline Dwfl_Error
diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c
index 9d0c786b..0171c1dc 100644
--- a/libdwfl/dwfl_module_getsrc_file.c
+++ b/libdwfl/dwfl_module_getsrc_file.c
@@ -50,7 +50,6 @@
#include "libdwflP.h"
#include "../libdw/libdwP.h"
-
int
dwfl_module_getsrc_file (Dwfl_Module *mod,
const char *fname, int lineno, int column,
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
index 5cc6f3b0..9e063043 100644
--- a/libdwfl/find-debuginfo.c
+++ b/libdwfl/find-debuginfo.c
@@ -53,10 +53,6 @@
#include <unistd.h>
#include "system.h"
-/* ANDROID_CHANGE_BEGIN */
-#include <AndroidFixup.h>
-/* ANDROID_CHANGE_END */
-
/* Try to open64 [DIR/][SUBDIR/]DEBUGLINK, return file descriptor or -1.
On success, *DEBUGINFO_FILE_NAME has the malloc'd name of the open file. */
static int
diff --git a/libdwfl/offline.c b/libdwfl/offline.c
index ba8f47c8..b3a95dd9 100644
--- a/libdwfl/offline.c
+++ b/libdwfl/offline.c
@@ -51,10 +51,6 @@
#include <fcntl.h>
#include <unistd.h>
-/* ANDROID_CHANGE_BEGIN */
-#include <AndroidFixup.h>
-/* ANDROID_CHANGE_END */
-
/* Since dwfl_report_elf lays out the sections already, this will only be
called when the section headers of the debuginfo file are being
consulted instead, or for the section placed at 0. With binutils
diff --git a/libebl/Android.mk b/libebl/Android.mk
new file mode 100755
index 00000000..19b0d682
--- /dev/null
+++ b/libebl/Android.mk
@@ -0,0 +1,123 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+supported_platforms := linux-x86 darwin-x86
+cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
+
+ifdef cur_platform
+
+#
+# host libebl
+#
+#
+include $(CLEAR_VARS)
+
+LIBEBL_SRC_FILES := \
+ eblauxvinfo.c \
+ eblbackendname.c \
+ eblbsspltp.c \
+ eblcheckobjattr.c \
+ ebl_check_special_section.c \
+ ebl_check_special_symbol.c \
+ eblclosebackend.c \
+ eblcopyrelocp.c \
+ eblcorenote.c \
+ eblcorenotetypename.c \
+ ebldebugscnp.c \
+ ebldynamictagcheck.c \
+ ebldynamictagname.c \
+ eblelfclass.c \
+ eblelfdata.c \
+ eblelfmachine.c \
+ eblgotpcreloccheck.c \
+ eblgstrtab.c \
+ eblmachineflagcheck.c \
+ eblmachineflagname.c \
+ eblmachinesectionflagcheck.c \
+ eblnonerelocp.c \
+ eblobjecttypename.c \
+ eblobjnote.c \
+ eblobjnotetypename.c \
+ eblopenbackend.c \
+ eblosabiname.c \
+ eblreginfo.c \
+ eblrelativerelocp.c \
+ eblrelocsimpletype.c \
+ eblreloctypecheck.c \
+ eblreloctypename.c \
+ eblrelocvaliduse.c \
+ eblretval.c \
+ eblsectionname.c \
+ eblsectionstripp.c \
+ eblsectiontypename.c \
+ eblshflagscombine.c \
+ eblstrtab.c \
+ eblsymbolbindingname.c \
+ eblsymboltypename.c \
+ ebl_syscall_abi.c \
+ eblsysvhashentrysize.c
+
+LOCAL_SRC_FILES := $(LIBEBL_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libebl \
+ $(LOCAL_PATH)/../libasm \
+ $(LOCAL_PATH)/../libelf \
+ $(LOCAL_PATH)/../libdw
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../host-$(HOST_OS)-fixup
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE
+
+LOCAL_CFLAGS += -include $(LOCAL_PATH)/../host-$(HOST_OS)-fixup/AndroidFixup.h
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE:= libebl
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+#
+# target libebl
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(LIBEBL_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libebl \
+ $(LOCAL_PATH)/../libasm \
+ $(LOCAL_PATH)/../libelf \
+ $(LOCAL_PATH)/../libdw
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../bionic-fixup
+
+LOCAL_CFLAGS += -include $(LOCAL_PATH)/../bionic-fixup/AndroidFixup.h
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -Werror
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE:= libebl
+
+include $(BUILD_STATIC_LIBRARY)
+
+endif #cur_platform
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 8cf42189..fda6b1ed 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -196,8 +196,15 @@ static bool default_object_note (const char *name, uint32_t type,
uint32_t descsz, const char *desc);
static bool default_debugscn_p (const char *name);
static bool default_copy_reloc_p (int reloc);
+/* ANDROID_CHANGE_BEGIN */
+#ifndef __APPLE__
static bool default_none_reloc_p (int reloc);
static bool default_relative_reloc_p (int reloc);
+#else
+#define default_none_reloc_p default_copy_reloc_p
+#define default_relative_reloc_p default_copy_reloc_p
+#endif
+/* ANDROID_CHANGE_END */
static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
const GElf_Sym *sym,
const char *name,
@@ -677,8 +684,12 @@ default_copy_reloc_p (int reloc __attribute__ ((unused)))
{
return false;
}
+/* ANDROID_CHANGE_BEGIN */
+#ifndef __APPLE__
strong_alias (default_copy_reloc_p, default_none_reloc_p)
strong_alias (default_copy_reloc_p, default_relative_reloc_p)
+#endif
+/* ANDROID_CHANGE_END */
static bool
default_check_special_symbol (Elf *elf __attribute__ ((unused)),
diff --git a/libelf/Android.mk b/libelf/Android.mk
new file mode 100755
index 00000000..78233d0c
--- /dev/null
+++ b/libelf/Android.mk
@@ -0,0 +1,193 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+supported_platforms := linux-x86 darwin-x86
+cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
+
+ifdef cur_platform
+
+#
+# host libelf
+#
+
+include $(CLEAR_VARS)
+
+LIBELF_SRC_FILES := \
+ elf32_checksum.c \
+ elf32_fsize.c \
+ elf32_getehdr.c \
+ elf32_getphdr.c \
+ elf32_getshdr.c \
+ elf32_newehdr.c \
+ elf32_newphdr.c \
+ elf32_offscn.c \
+ elf32_updatefile.c \
+ elf32_updatenull.c \
+ elf32_xlatetof.c \
+ elf32_xlatetom.c \
+ elf64_checksum.c \
+ elf64_fsize.c \
+ elf64_getehdr.c \
+ elf64_getphdr.c \
+ elf64_getshdr.c \
+ elf64_newehdr.c \
+ elf64_newphdr.c \
+ elf64_offscn.c \
+ elf64_updatefile.c \
+ elf64_updatenull.c \
+ elf64_xlatetof.c \
+ elf64_xlatetom.c \
+ elf_begin.c \
+ elf_clone.c \
+ elf_cntl.c \
+ elf_end.c \
+ elf_error.c \
+ elf_fill.c \
+ elf_flagdata.c \
+ elf_flagehdr.c \
+ elf_flagelf.c \
+ elf_flagphdr.c \
+ elf_flagscn.c \
+ elf_flagshdr.c \
+ elf_getarhdr.c \
+ elf_getaroff.c \
+ elf_getarsym.c \
+ elf_getbase.c \
+ elf_getdata.c \
+ elf_getdata_rawchunk.c \
+ elf_getident.c \
+ elf_getscn.c \
+ elf_getshnum.c \
+ elf_getshstrndx.c \
+ elf_gnu_hash.c \
+ elf_hash.c \
+ elf_kind.c \
+ elf_memory.c \
+ elf_ndxscn.c \
+ elf_newdata.c \
+ elf_newscn.c \
+ elf_next.c \
+ elf_nextscn.c \
+ elf_rand.c \
+ elf_rawdata.c \
+ elf_rawfile.c \
+ elf_readall.c \
+ elf_scnshndx.c \
+ elf_strptr.c \
+ elf_update.c \
+ elf_version.c \
+ gelf_checksum.c \
+ gelf_fsize.c \
+ gelf_getauxv.c \
+ gelf_getclass.c \
+ gelf_getdyn.c \
+ gelf_getehdr.c \
+ gelf_getlib.c \
+ gelf_getmove.c \
+ gelf_getnote.c \
+ gelf_getphdr.c \
+ gelf_getrela.c \
+ gelf_getrel.c \
+ gelf_getshdr.c \
+ gelf_getsym.c \
+ gelf_getsyminfo.c \
+ gelf_getsymshndx.c \
+ gelf_getverdaux.c \
+ gelf_getverdef.c \
+ gelf_getvernaux.c \
+ gelf_getverneed.c \
+ gelf_getversym.c \
+ gelf_newehdr.c \
+ gelf_newphdr.c \
+ gelf_offscn.c \
+ gelf_update_auxv.c \
+ gelf_update_dyn.c \
+ gelf_update_ehdr.c \
+ gelf_update_lib.c \
+ gelf_update_move.c \
+ gelf_update_phdr.c \
+ gelf_update_rela.c \
+ gelf_update_rel.c \
+ gelf_update_shdr.c \
+ gelf_update_sym.c \
+ gelf_update_syminfo.c \
+ gelf_update_symshndx.c \
+ gelf_update_verdaux.c \
+ gelf_update_verdef.c \
+ gelf_update_vernaux.c \
+ gelf_update_verneed.c \
+ gelf_update_versym.c \
+ gelf_xlate.c \
+ gelf_xlatetof.c \
+ gelf_xlatetom.c \
+ libelf_crc32.c \
+ libelf_next_prime.c \
+ nlist.c
+
+LOCAL_SRC_FILES := $(LIBELF_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libelf
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../host-$(HOST_OS)-fixup
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE
+
+# to suppress the "pointer of type ‘void *’ used in arithmetic" warning
+LOCAL_CFLAGS += -Wno-pointer-arith
+
+ifeq ($(HOST_OS),darwin)
+ LOCAL_CFLAGS += -fnested-functions
+endif
+
+# to fix machine-dependent issues
+LOCAL_CFLAGS += -include $(LOCAL_PATH)/../host-$(HOST_OS)-fixup/AndroidFixup.h
+
+LOCAL_MODULE := libelf
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+#
+# target libelf
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(LIBELF_SRC_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../libelf
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../bionic-fixup
+
+LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -Werror
+
+# to suppress the "pointer of type ‘void *’ used in arithmetic" warning
+LOCAL_CFLAGS += -Wno-pointer-arith
+
+LOCAL_CFLAGS += -include $(LOCAL_PATH)/../bionic-fixup/AndroidFixup.h
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE := libelf
+
+include $(BUILD_STATIC_LIBRARY)
+
+endif #cur_platform
diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c
index 5af0f7f3..a655cb05 100644
--- a/libelf/elf_getdata_rawchunk.c
+++ b/libelf/elf_getdata_rawchunk.c
@@ -64,7 +64,13 @@
Elf_Data *
elf_getdata_rawchunk (elf, offset, size, type)
Elf *elf;
+ /* ANDROID_CHANGE_BEGIN */
+#if 0
off64_t offset;
+#else
+ off_t offset;
+#endif
+ /* ANDROID_CHANGE_END */
size_t size;
Elf_Type type;
{
@@ -78,8 +84,15 @@ elf_getdata_rawchunk (elf, offset, size, type)
return NULL;
}
+ /* ANDROID_CHANGE_BEGIN */
+#if 0
if (unlikely (size > elf->maximum_size
|| (off64_t) (elf->maximum_size - size) < offset))
+#else
+ if (unlikely (size > elf->maximum_size
+ || (off_t) (elf->maximum_size - size) < offset))
+#endif
+ /* ANDROID_CHANGE_END */
{
/* Invalid request. */
__libelf_seterrno (ELF_E_INVALID_OP);
diff --git a/libelf/libelf.h b/libelf/libelf.h
index dea0d838..8021266a 100644
--- a/libelf/libelf.h
+++ b/libelf/libelf.h
@@ -95,7 +95,13 @@ typedef struct
Elf_Type d_type; /* Type of this piece of data. */
unsigned int d_version; /* ELF version. */
size_t d_size; /* Size in bytes. */
+ /* ANDROID_CHANGE_BEGIN */
+#if 0
loff_t d_off; /* Offset into section. */
+#else
+ off_t d_off; /* Offset into section. */
+#endif
+ /* ANDROID_CHANGE_END */
size_t d_align; /* Alignment in section. */
} Elf_Data;
@@ -157,7 +163,13 @@ typedef struct
uid_t ar_uid; /* User ID. */
gid_t ar_gid; /* Group ID. */
mode_t ar_mode; /* File mode. */
+ /* ANDROID_CHANGE_BEGIN */
+#if 0
loff_t ar_size; /* File size. */
+#else
+ off_t ar_size; /* File size. */
+#endif
+ /* ANDROID_CHANGE_END */
char *ar_rawname; /* Original name of archive member. */
} Elf_Arhdr;
@@ -198,13 +210,25 @@ extern Elf_Cmd elf_next (Elf *__elf);
extern int elf_end (Elf *__elf);
/* Update ELF descriptor and write file to disk. */
-extern loff_t elf_update (Elf *__elf, Elf_Cmd __cmd);
+/* ANDROID_CHANGE_BEGIN */
+#if 0
+extern off_t elf_update (Elf *__elf, Elf_Cmd __cmd);
+#else
+#endif
+/* ANDROID_CHANGE_END */
+
/* Determine what kind of file is associated with ELF. */
extern Elf_Kind elf_kind (Elf *__elf) __attribute__ ((__pure__));
/* Get the base offset for an object file. */
+/* ANDROID_CHANGE_BEGIN */
+#if 0
extern loff_t elf_getbase (Elf *__elf);
+#else
+extern off_t elf_getbase (Elf *__elf);
+#endif
+/* ANDROID_CHANGE_END */
/* Retrieve file identification data. */
@@ -305,9 +329,17 @@ extern Elf_Data *elf_newdata (Elf_Scn *__scn);
/* Get data translated from a chunk of the file contents as section data
would be for TYPE. The resulting Elf_Data pointer is valid until
elf_end (ELF) is called. */
+/* ANDROID_CHANGE_BEGIN */
+#if 0
extern Elf_Data *elf_getdata_rawchunk (Elf *__elf,
loff_t __offset, size_t __size,
Elf_Type __type);
+#else
+extern Elf_Data *elf_getdata_rawchunk (Elf *__elf,
+ off_t __offset, size_t __size,
+ Elf_Type __type);
+#endif
+/* ANDROID_CHANGE_END */
/* Return pointer to string at OFFSET in section INDEX. */
@@ -318,7 +350,13 @@ extern char *elf_strptr (Elf *__elf, size_t __index, size_t __offset);
extern Elf_Arhdr *elf_getarhdr (Elf *__elf);
/* Return offset in archive for current file ELF. */
+/* ANDROID_CHANGE_BEGIN */
+#if 0
extern loff_t elf_getaroff (Elf *__elf);
+#else
+extern off_t elf_getaroff (Elf *__elf);
+#endif
+/* ANDROID_CHANGE_END */
/* Select archive element at OFFSET. */
extern size_t elf_rand (Elf *__elf, size_t __offset);