misc fixes:

* fix gcc warnings (even though they are not my fault)
* fix a typo in include/foreign/i386/_types.h (__INT64_TYPE_ -> __INT64_TYPE__)
* fix the cygwin + clang<=3.4 build
This commit is contained in:
Thomas Pöchtrager 2015-03-09 20:01:33 +01:00
parent 3f00c16b0f
commit 0c32be78e9
16 changed files with 89 additions and 39 deletions

View File

@ -4457,6 +4457,8 @@ parse_operands (char *str, const unsigned char *pattern)
enum arm_reg_type rtype;
parse_operand_result result;
val = 0; /* cctools-port */
#define po_char_or_fail(chr) do { \
if (skip_past_char (&str, chr) == FAIL) \
goto bad_args; \
@ -17839,7 +17841,7 @@ md_apply_fix (fixS * fixP,
{
bfd_vma insn;
bfd_vma encoded_addend;
bfd_vma addend_abs = abs ((int)value);
bfd_vma addend_abs = abs ((int)value); /* cctools-port: added (int) */
/* Check that the absolute value of the addend can be
expressed as an 8-bit constant plus a rotation. */
@ -17884,7 +17886,7 @@ md_apply_fix (fixS * fixP,
#endif
{
bfd_vma insn;
bfd_vma addend_abs = abs ((int)value);
bfd_vma addend_abs = abs ((int)value); /* cctools-port: added (int) */
/* Check that the absolute value of the addend can be
encoded in 12 bits. */
@ -17927,7 +17929,7 @@ md_apply_fix (fixS * fixP,
#endif
{
bfd_vma insn;
bfd_vma addend_abs = abs ((int)value);
bfd_vma addend_abs = abs ((int)value); /* cctools-port: added (int) */
/* Check that the absolute value of the addend can be
encoded in 8 bits. */
@ -17971,7 +17973,7 @@ md_apply_fix (fixS * fixP,
#endif
{
bfd_vma insn;
bfd_vma addend_abs = abs ((int)value);
bfd_vma addend_abs = abs ((int)value); /* cctools-port: added (int) */
/* Check that the absolute value of the addend is a multiple of
four and, when divided by four, fits in 8 bits. */

View File

@ -41,6 +41,8 @@ fi
CWARNINGS=""
OBJCWARNINGS=""
CXXWARNINGS=""
EXTRAFLAGS=""
EXTRACXXFLAGS=""
WARNINGS=""
case $host_os in
@ -54,10 +56,7 @@ case $host_os in
;;
cygwin* )
iscygwin=yes
CYGFLAGS="-D__LARGE64_FILES -fno-PIC"
CFLAGS="$CFLAGS $CYGFLAGS"
OBJCFLAGS="$OBJCFLAGS $CYGFLAGS"
CXXFLAGS="$CXXFLAGS $CYGFLAGS"
EXTRAFLAGS="-D__LARGE64_FILES -fno-PIC"
WARNINGS="-Wno-attributes"
if test "x$CC" = "x"; then CC="gcc"; fi
if test "x$CXX" = "x"; then CXX="g++"; fi
@ -94,7 +93,6 @@ case "`$CC --version`" in
WARNINGS="$WARNINGS -Wno-unused-but-set-variable -Wno-deprecated -Wno-deprecated-declarations"
WARNINGS="$WARNINGS -Wno-char-subscripts -Wno-strict-aliasing"
OBJCWARNINGS="-Wall"
# TODO: GCC5 needs -Wno-int-conversion
CFLAGS="$CFLAGS -std=gnu99 $CFLAGS -D__private_extern__= "
CXXFLAGS="$CXXFLAGS -D__private_extern__="
;;
@ -107,11 +105,23 @@ case "`$CXX --version`" in
fi
# can't use -fblocks on cyggwin due to a clang driver bug
if test "x$iscygwin" = "xno"; then
CXXFLAGS="$CXXFLAGS -fblocks"
EXTRACXXFLAGS="$EXTRACXXFLAGS -fblocks"
else
EXTRAFLAGS="$EXTRAFLAGS -integrated-as"
fi
;;
esac
if test "x$EXTRAFLAGS" != "x"; then
CFLAGS="$CFLAGS $EXTRAFLAGS"
OBJCFLAGS="$OBJCFLAGS $EXTRAFLAGS"
CXXFLAGS="$CXXFLAGS $EXTRAFLAGS"
fi
if test "xEXTRACXXFLAGS" != "x"; then
CXXFLAGS="$CXXFLAGS $EXTRACXXFLAGS"
fi
AC_SUBST([WARNINGS], [$WARNINGS])
AC_SUBST([OBJCWARNINGS], [$OBJCWARNINGS])

View File

@ -56,8 +56,8 @@ typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
#ifdef __INT64_TYPE_
typedef __INT64_TYPE_ __int64_t;
#ifdef __INT64_TYPE__
typedef __INT64_TYPE__ __int64_t;
typedef unsigned __INT64_TYPE__ __uint64_t;
#else
#if __SIZEOF_POINTER__ == 8 && !defined(__CYGWIN__)

View File

@ -227,6 +227,7 @@ ld::File* InputFiles::makeFile(const Options::FileInfo& info, bool indirectDylib
bool isFatFile = false;
uint32_t sliceToUse, sliceCount;
const fat_header* fh = (fat_header*)p;
sliceCount = 0; // ld64-port
if ( fh->magic == OSSwapBigToHostInt32(FAT_MAGIC) ) {
isFatFile = true;
const struct fat_arch* archs = (struct fat_arch*)(p + sizeof(struct fat_header));

View File

@ -398,6 +398,16 @@ private:
}
};
//
// ld64-port:
// silence a false positive uninitialized variable warning:
// warning: '*((void*)& picker +24)' may be used uninitialized in this function
//
#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
bool SymbolTable::addByName(const ld::Atom& newAtom, bool ignoreDuplicates)
{
bool useNew = true;
@ -407,6 +417,7 @@ bool SymbolTable::addByName(const ld::Atom& newAtom, bool ignoreDuplicates)
const ld::Atom* existingAtom = _indirectBindingTable[slot];
//fprintf(stderr, "addByName(%p) name=%s, slot=%u, existing=%p\n", &newAtom, newAtom.name(), slot, existingAtom);
if ( existingAtom != NULL ) {
assert(&newAtom != existingAtom);
NameCollisionResolution picker(newAtom, *existingAtom, ignoreDuplicates, _options);
if (picker.reportDuplicate()) {
@ -433,6 +444,9 @@ bool SymbolTable::addByName(const ld::Atom& newAtom, bool ignoreDuplicates)
return useNew && (existingAtom != NULL);
}
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
bool SymbolTable::addByContent(const ld::Atom& newAtom)
{

View File

@ -417,7 +417,7 @@ void UnwindPrinter<x86_64>::decode(uint32_t encoding, const uint8_t* funcStart,
// renumber registers back to standard numbers
int registers[6];
bool used[7] = { false, false, false, false, false, false, false };
for (int i=0; i < regCount; ++i) {
for (uint32_t i=0; i < regCount; ++i) { // ld64-port: int -> uint32_t
int renum = 0;
for (int u=1; u < 7; ++u) {
if ( !used[u] ) {
@ -431,7 +431,7 @@ void UnwindPrinter<x86_64>::decode(uint32_t encoding, const uint8_t* funcStart,
}
}
bool needComma = false;
for (int i=0; i < regCount; ++i) {
for (uint32_t i=0; i < regCount; ++i) { // ld64-port: int -> uint32_t
if ( needComma )
strcat(str, ",");
else
@ -598,7 +598,7 @@ void UnwindPrinter<x86>::decode(uint32_t encoding, const uint8_t* funcStart, cha
// renumber registers back to standard numbers
int registers[6];
bool used[7] = { false, false, false, false, false, false, false };
for (int i=0; i < regCount; ++i) {
for (uint32_t i=0; i < regCount; ++i) { // ld64-port: int -> uint32_t
int renum = 0;
for (int u=1; u < 7; ++u) {
if ( !used[u] ) {
@ -612,7 +612,7 @@ void UnwindPrinter<x86>::decode(uint32_t encoding, const uint8_t* funcStart, cha
}
}
bool needComma = false;
for (int i=0; i < regCount; ++i) {
for (uint32_t i=0; i < regCount; ++i) { // ld64-port: int -> uint32_t
if ( needComma )
strcat(str, ",");
else

View File

@ -16,9 +16,10 @@
pthread_key_t ARCThreadKey;
#endif
extern void _NSConcreteMallocBlock;
extern void _NSConcreteStackBlock;
extern void _NSConcreteGlobalBlock;
// cctools-port void -> char []
extern char _NSConcreteMallocBlock[];
extern char _NSConcreteStackBlock[];
extern char _NSConcreteGlobalBlock[];
@interface NSAutoreleasePool
+ (Class)class;
@ -191,13 +192,13 @@ static inline void release(id obj)
{
if (isSmallObject(obj)) { return; }
Class cls = obj->isa;
if (cls == &_NSConcreteMallocBlock)
if (cls == (Class)&_NSConcreteMallocBlock) // cctools-port: added (Class)
{
_Block_release(obj);
return;
}
if ((cls == &_NSConcreteStackBlock) ||
(cls == &_NSConcreteGlobalBlock))
if ((cls == (Class)&_NSConcreteStackBlock) || // cctools-port: added (Class)
(cls == (Class)&_NSConcreteGlobalBlock)) // cctools-port: added (Class)
{
return;
}
@ -554,7 +555,7 @@ id objc_storeWeak(id *addr, id obj)
return nil;
}
Class cls = classForObject(obj);
if (&_NSConcreteGlobalBlock == cls)
if ((Class)&_NSConcreteGlobalBlock == cls) // cctools-port: added (Class)
{
// If this is a global block, it's never deallocated, so secretly make
// this a strong reference
@ -563,7 +564,7 @@ id objc_storeWeak(id *addr, id obj)
*addr = obj;
return obj;
}
if (&_NSConcreteMallocBlock == cls)
if ((Class)&_NSConcreteMallocBlock == cls) // cctools-port: added (Class)
{
obj = block_load_weak(obj);
}
@ -651,7 +652,7 @@ id objc_loadWeakRetained(id* addr)
id obj = *addr;
if (nil == obj) { return nil; }
Class cls = classForObject(obj);
if (&_NSConcreteMallocBlock == cls)
if ((Class)&_NSConcreteMallocBlock == cls) // cctools-port: added (Class)
{
obj = block_load_weak(obj);
}

View File

@ -108,10 +108,11 @@ static struct wx_buffer alloc_buffer(size_t size)
return b;
}
extern void __objc_block_trampoline;
extern void __objc_block_trampoline_end;
extern void __objc_block_trampoline_sret;
extern void __objc_block_trampoline_end_sret;
// cctools-port void -> char []
extern char __objc_block_trampoline[];
extern char __objc_block_trampoline_end[];
extern char __objc_block_trampoline_sret[];
extern char __objc_block_trampoline_end_sret[];
IMP imp_implementationWithBlock(void *block)
{

View File

@ -237,8 +237,9 @@ void *_Block_copy(void *src)
struct Block_layout *self = src;
struct Block_layout *ret = self;
extern void _NSConcreteStackBlock;
extern void _NSConcreteMallocBlock;
// cctools-port void -> char []
extern char _NSConcreteStackBlock[];
extern char _NSConcreteMallocBlock[];
// If the block is Global, there's no need to copy it on the heap.
if(self->isa == &_NSConcreteStackBlock)
@ -270,8 +271,9 @@ void _Block_release(void *src)
if (NULL == src) { return; }
struct Block_layout *self = src;
extern void _NSConcreteStackBlock;
extern void _NSConcreteMallocBlock;
// cctools-port void -> char []
extern char _NSConcreteStackBlock[];
extern char _NSConcreteMallocBlock[];
if (&_NSConcreteStackBlock == self->isa)
{

View File

@ -340,7 +340,7 @@ static void *PREFIX(_table_get_cell)(PREFIX(_table) *table, const void *key)
// Value does not exist.
if (!MAP_TABLE_VALUE_NULL(cell->value))
{
if (MAP_TABLE_COMPARE_FUNCTION(key, cell->value))
if (MAP_TABLE_COMPARE_FUNCTION((void*)key, cell->value)) // cctools-port: added (void*)
{
return cell;
}
@ -349,7 +349,7 @@ static void *PREFIX(_table_get_cell)(PREFIX(_table) *table, const void *key)
for (int hop = __builtin_ffs(jump) ; hop > 0 ; hop = __builtin_ffs(jump))
{
PREFIX(_table_cell) hopCell = PREFIX(_table_lookup)(table, hash+hop);
if (MAP_TABLE_COMPARE_FUNCTION(key, hopCell->value))
if (MAP_TABLE_COMPARE_FUNCTION((void*)key, hopCell->value)) // cctools-port: added (void*)
{
return hopCell;
}

View File

@ -56,7 +56,9 @@ struct objc_slot* (*_objc_selector_type_mismatch)(Class cls, SEL
static
// Uncomment for debugging
//__attribute__((noinline))
#ifdef __clang__ // cctools-port
__attribute__((always_inline))
#endif
Slot_t objc_msg_lookup_internal(id *receiver,
SEL selector,
id sender)

View File

@ -499,6 +499,8 @@ void *cookie)
char *short_name, *has_suffix;
enum bool is_framework;
memset(&process_flags, '\0', sizeof(process_flags)); /* cctools-port */
cmd_flags = (struct cmd_flags *)cookie;
process_flags.nsect = -1;

View File

@ -11,7 +11,11 @@ $(top_srcdir)/libobjc2/libobjc.la \
$(PTHREAD_FLAGS) $(CXXABI_LIB) $(DL_LIB)
endif
if ISDARWIN
otool_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff $(WARNINGS) $(LTO_DEF) -D_DARWIN_C_SOURCE -D__DARWIN_UNIX03 $(ENDIAN_FLAG) -DOTOOL
else
otool_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/foreign -I$(top_srcdir)/libstuff -I$(top_srcdir)/libobjc2 $(WARNINGS) $(LTO_DEF) -D_DARWIN_C_SOURCE -D__DARWIN_UNIX03 $(ENDIAN_FLAG) -DOTOOL
endif
otool_SOURCES = \
main.c \

View File

@ -2837,6 +2837,8 @@ uint64_t *ndbi)
uint8_t *start, *end;
const char **dylibs;
a = NULL; /* cctools-port */
/* If already setup just return. */
if(*dbi != NULL)
return;

View File

@ -1177,6 +1177,8 @@ enum bool verbose)
char buf[20];
uint64_t big_size;
str_size = 0; /* cctools-port */
host_byte_sex = get_host_byte_sex();
toc_offset = 0;
strings = NULL;
@ -7866,6 +7868,8 @@ enum bool print_addresses)
uint32_t n_strx;
uint64_t big_load_end, big_size;
d = 0.0; /* cctools-port */
host_byte_sex = get_host_byte_sex();
swapped = host_byte_sex != object_byte_sex;

View File

@ -30,6 +30,7 @@
*/
#include "stdio.h"
#include "string.h"
#include "stdint.h" /* cctools-port: intptr_t */
#include "mach-o/loader.h"
#include "objc/runtime.h"
#include "stuff/allocate.h"
@ -636,7 +637,8 @@ print_objc_class:
printf("\n");
printf("\t\t isa 0x%08x", objc_class.isa);
if(verbose && objc_getMetaClass(objc_class.name)){
/* cctools-port: added (const char*)(intptr_t) */
if(verbose && objc_getMetaClass((const char*)(intptr_t)objc_class.name)){
p = get_pointer(objc_class.isa, &left, objc_sections,
nobjc_sections, &cstring_section);
if(p != NULL)
@ -675,9 +677,11 @@ print_objc_class:
printf("\t\t info 0x%08x",
(unsigned int)objc_class.info);
if(verbose){
if(objc_getClass(objc_class.name))
/* cctools-port: added (const char*)(intptr_t) */
if(objc_getClass((const char*)(intptr_t)objc_class.name))
printf(" CLS_CLASS\n");
else if(objc_getMetaClass(objc_class.name))
/* cctools-port: added (const char*)(intptr_t) */
else if(objc_getMetaClass((const char*)(intptr_t)objc_class.name))
printf(" CLS_META\n");
else
printf("\n");
@ -767,7 +771,8 @@ print_objc_class:
host_byte_sex, swapped, verbose) == FALSE)
printf(" (not in an " SEG_OBJC " section)\n");
if(objc_getClass(objc_class.name)){
/* cctools-port: added (const char*)(intptr_t) */
if(objc_getClass((const char*)(intptr_t)objc_class.name)){
printf("\tMeta Class");
if(get_objc_class((uint32_t)objc_class.isa,
&objc_class, &trunc, objc_sections, nobjc_sections,