diff options
author | Ben Cheng <bccheng@google.com> | 2012-03-26 15:59:46 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2012-03-26 15:59:46 -0700 |
commit | fd9379427bd93f38adb15876bb25297dbe04ecc4 (patch) | |
tree | f71ca707640c515ae2f4d6ba7976bfeea90a3fd4 | |
parent | fac061ffdea9dc61a3b7c53cb85a44594a4354ba (diff) | |
download | android_external_elfutils-fd9379427bd93f38adb15876bb25297dbe04ecc4.tar.gz android_external_elfutils-fd9379427bd93f38adb15876bb25297dbe04ecc4.tar.bz2 android_external_elfutils-fd9379427bd93f38adb15876bb25297dbe04ecc4.zip |
Tweak the host version of elfutils for MacOS.
Change-Id: I806cdda2782b00832c7d851664fdba64cce92c0e
-rw-r--r-- | host-darwin-fixup/AndroidFixup.h | 22 | ||||
-rw-r--r-- | host-darwin-fixup/getline.c | 49 | ||||
-rwxr-xr-x | libdw/Android.mk | 5 | ||||
-rwxr-xr-x | libdwfl/Android.mk | 3 | ||||
-rw-r--r-- | libdwfl/dwfl_build_id_find_elf.c | 2 | ||||
-rw-r--r-- | libdwfl/find-debuginfo.c | 4 |
6 files changed, 82 insertions, 3 deletions
diff --git a/host-darwin-fixup/AndroidFixup.h b/host-darwin-fixup/AndroidFixup.h index 1342843f..2235835c 100644 --- a/host-darwin-fixup/AndroidFixup.h +++ b/host-darwin-fixup/AndroidFixup.h @@ -72,4 +72,26 @@ static inline char *dcgettext (char *__domainname, char *__msgid, int __category return NULL; } +/* workaround for canonicalize_file_name */ +#define canonicalize_file_name(path) realpath(path, NULL) + +/* workaround for open64 */ +#define open64(path, flags) open(path, flags) + +/* rawmemchr */ +static inline void *rawmemchr(const void *s, int c) +{ + const unsigned char *ptr = s; + while (1) { + if (*ptr == c) return (void *) ptr; + ptr++; + } +} + +#define strndup(str, size) strdup(str) + +static void tdestroy(void *root, void (*free_node)(void *nodep)) +{ +} + #endif /* ANDROID_FIXUP_H */ diff --git a/host-darwin-fixup/getline.c b/host-darwin-fixup/getline.c new file mode 100644 index 00000000..041a5ed9 --- /dev/null +++ b/host-darwin-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/libdw/Android.mk b/libdw/Android.mk index 44f0223a..9f4708d7 100755 --- a/libdw/Android.mk +++ b/libdw/Android.mk @@ -128,12 +128,17 @@ LOCAL_C_INCLUDES := \ ifeq ($(HOST_OS),darwin) LOCAL_CFLAGS += -fnested-functions + LOCAL_SRC_FILES += \ + ../host-darwin-fixup/getline.c endif LOCAL_C_INCLUDES += $(LOCAL_PATH)/../host-$(HOST_OS)-fixup LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE -DIS_LIBDW +# to fix machine-dependent issues +LOCAL_CFLAGS += -include $(LOCAL_PATH)/../host-$(HOST_OS)-fixup/AndroidFixup.h + LOCAL_MODULE_TAGS := optional LOCAL_MODULE:= libdw diff --git a/libdwfl/Android.mk b/libdwfl/Android.mk index 71a7ddbe..3effccc1 100755 --- a/libdwfl/Android.mk +++ b/libdwfl/Android.mk @@ -63,6 +63,9 @@ 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_TAGS := optional LOCAL_MODULE:= libdwfl diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c index 21c77190..28bf5fd7 100644 --- a/libdwfl/dwfl_build_id_find_elf.c +++ b/libdwfl/dwfl_build_id_find_elf.c @@ -85,7 +85,7 @@ __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name) const Dwfl_Callbacks *const cb = mod->dwfl->callbacks; /* ANDROID_CHANGE_BEGIN */ -#ifdef __BIONIC__ +#if defined(__BIONIC__) || defined(__APPLE__) char *path = strdup ((cb->debuginfo_path ? *cb->debuginfo_path : NULL) ?: DEFAULT_DEBUGINFO_PATH); #else diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 9e063043..c58997d1 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -145,7 +145,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, const Dwfl_Callbacks *const cb = mod->dwfl->callbacks; /* ANDROID_CHANGE_BEGIN */ -#ifdef __BIONIC__ +#if defined(__BIONIC__) || defined(__APPLE__) char *path = strdup ((cb->debuginfo_path ? *cb->debuginfo_path : NULL) ?: DEFAULT_DEBUGINFO_PATH); #else @@ -163,7 +163,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, } /* ANDROID_CHANGE_BEGIN */ -#ifdef __BIONIC__ +#if defined(__BIONIC__) || defined(__APPLE__) char *file_dirname = (file_basename == file_name ? NULL : strndup (file_name, file_basename - 1 - file_name)); #else |