Skip to content

Commit

Permalink
cctools-855
Browse files Browse the repository at this point in the history
Imported from cctools-855.tar.gz
  • Loading branch information
AppleOSSDistributions committed Oct 6, 2021
1 parent 80748c1 commit 69dfa55
Show file tree
Hide file tree
Showing 65 changed files with 2,869 additions and 193 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ DSTROOT = /
RC_OS = macos
RC_CFLAGS =


INSTALLSRC_SUBDIRS = $(COMMON_SUBDIRS) $(SUBDIRS_32) ar include efitools \
libmacho
COMMON_SUBDIRS = libstuff as gprof misc man cbtlibs otool
Expand Down Expand Up @@ -54,7 +53,7 @@ all clean: $(DSTROOT)
done; \
SED_RC_CFLAGS=`echo "$(RC_CFLAGS)" | sed 's/-arch ppc64//' \
| sed 's/-arch x86_64//' | sed 's/-arch armv5//' \
| sed 's/-arch arm64//' \
| sed 's/-arch arm64//' | sed 's/-arch x86_64h//' \
| sed 's/-arch armv6//' | sed 's/-arch armv7[f,k,s]*//g'`; \
EMPTY=`echo "$$SED_RC_CFLAGS" | sed 's/ //g' \
| sed 's/-pipe//'`; \
Expand Down Expand Up @@ -86,7 +85,7 @@ all clean: $(DSTROOT)
done; \
SED_RC_CFLAGS=`echo "$(RC_CFLAGS)" | sed 's/-arch ppc64//' \
| sed 's/-arch x86_64//' | sed 's/-arch armv5//' \
| sed 's/-arch arm64//' \
| sed 's/-arch arm64//' | sed 's/-arch x86_64h//' \
| sed 's/-arch armv6//' | sed 's/-arch armv7[f,k,s]*//g'`; \
EMPTY=`echo "$$SED_RC_CFLAGS" | sed 's/ //g' \
| sed 's/-pipe//'`; \
Expand Down Expand Up @@ -162,7 +161,7 @@ install_tools: installhdrs
done; \
SED_RC_CFLAGS=`echo "$(RC_CFLAGS)" | sed 's/-arch ppc64//' \
| sed 's/-arch x86_64//' | sed 's/-arch armv5//' \
| sed 's/-arch arm64//' \
| sed 's/-arch arm64//' | sed 's/-arch x86_64h//' \
| sed 's/-arch armv6//' | sed 's/-arch armv7[f,k,s]*//g'`; \
EMPTY=`echo "$$SED_RC_CFLAGS" | sed 's/ //g' \
| sed 's/-pipe//'`; \
Expand Down Expand Up @@ -195,7 +194,7 @@ install_tools: installhdrs
done; \
SED_RC_CFLAGS=`echo "$(RC_CFLAGS)" | sed 's/-arch ppc64//' \
| sed 's/-arch x86_64//' | sed 's/-arch armv5//' \
| sed 's/-arch arm64//' \
| sed 's/-arch arm64//' | sed 's/-arch x86_64h//' \
| sed 's/-arch armv6//' | sed 's/-arch armv7[f,k,s]*//g'`; \
EMPTY=`echo "$$SED_RC_CFLAGS" | sed 's/ //g' \
| sed 's/-pipe//'`; \
Expand Down Expand Up @@ -232,6 +231,7 @@ lib_ofiles lib_ofiles_install: installhdrs
CWD=`pwd`; cd "$(DSTROOT)"; DSTROOT=`pwd`; cd "$$CWD"; \
SED_RC_CFLAGS=`echo "$(RC_CFLAGS)" | sed 's/-arch ppc64//' \
| sed 's/-arch arm64//' \
| sed 's/-arch x86_64h//' \
| sed 's/-arch x86_64//'`; \
echo =========== $(MAKE) $@ for libstuff =============; \
(cd libstuff; $(MAKE) "RC_CFLAGS=$(RC_CFLAGS) $(HIDE)" \
Expand Down Expand Up @@ -287,6 +287,7 @@ lib_ofiles lib_ofiles_install: installhdrs
CWD=`pwd`; cd "$(DSTROOT)"; DSTROOT=`pwd`; cd "$$CWD"; \
SED_RC_CFLAGS=`echo "$(RC_CFLAGS)" | sed 's/-arch ppc64//' \
| sed 's/-arch arm64//' \
| sed 's/-arch x86_64h//' \
| sed 's/-arch x86_64//'`; \
echo =========== $(MAKE) $@ for libstuff =============; \
(cd libstuff; $(MAKE) "RC_CFLAGS=$(RC_CFLAGS) $(HIDE)" \
Expand Down
10 changes: 10 additions & 0 deletions as/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,17 @@ static arm_feature_set thumb_arch_used;
#endif /* INSNS_TABLE_ONLY */

/* Constants for known architecture features. */
#ifdef UNUSED
static const arm_feature_set fpu_arch_vfp_v1 = FPU_ARCH_VFP_V1;
static const arm_feature_set fpu_arch_vfp_v2 = FPU_ARCH_VFP_V2;
static const arm_feature_set fpu_arch_vfp_v3 = FPU_ARCH_VFP_V3;
static const arm_feature_set fpu_arch_neon_v1 = FPU_ARCH_NEON_V1;
static const arm_feature_set fpu_arch_fpa = FPU_ARCH_FPA;
#endif /* UNUSED */
static const arm_feature_set fpu_any_hard = FPU_ANY_HARD;
#ifdef UNUSED
static const arm_feature_set fpu_arch_maverick = FPU_ARCH_MAVERICK;
#endif /* UNUSED */
static const arm_feature_set fpu_endian_pure = FPU_ARCH_ENDIAN_PURE;

static const arm_feature_set arm_ext_v1 = ARM_FEATURE (ARM_EXT_V1, 0);
Expand All @@ -218,14 +222,20 @@ static const arm_feature_set arm_ext_v6t2 = ARM_FEATURE (ARM_EXT_V6T2, 0);
static const arm_feature_set arm_ext_v6_notm = ARM_FEATURE (ARM_EXT_V6_NOTM, 0);
static const arm_feature_set arm_ext_div = ARM_FEATURE (ARM_EXT_DIV, 0);
static const arm_feature_set arm_ext_v7 = ARM_FEATURE (ARM_EXT_V7, 0);
#ifdef UNUSED
static const arm_feature_set arm_ext_v7a = ARM_FEATURE (ARM_EXT_V7A, 0);
static const arm_feature_set arm_ext_v7r = ARM_FEATURE (ARM_EXT_V7R, 0);
#endif /* UNUSED */
static const arm_feature_set arm_ext_v7m = ARM_FEATURE (ARM_EXT_V7M, 0);

#ifdef UNUSED
static const arm_feature_set arm_arch_any = ARM_ANY;
#endif /* UNUSED */
static const arm_feature_set arm_arch_full = ARM_FEATURE (-1, -1);
static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2;
#ifdef UNUSED
static const arm_feature_set arm_arch_none = ARM_ARCH_NONE;
#endif /* UNUSED */

static const arm_feature_set arm_cext_iwmmxt2 =
ARM_FEATURE (0, ARM_CEXT_IWMMXT2);
Expand Down
6 changes: 6 additions & 0 deletions as/as.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ char **envp)
*work_argv = NULL; /* NULL means 'not a file-name' */
continue;
}
if(strncmp(arg, "-mcpu", 5) == 0){
/* ignore -mcpu as it is only used with clang(1)'s integrated
assembler, but the as(1) driver will pass it. */
*work_argv = NULL; /* NULL means 'not a file-name' */
continue;
}

/* Keep scanning args looking for flags. */
if (arg[1] == '-' && arg[2] == 0) {
Expand Down
68 changes: 58 additions & 10 deletions as/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ char **envp)
uint32_t bufsize;
struct arch_flag arch_flag;
const struct arch_flag *arch_flags, *family_arch_flag;
enum bool oflag_specified, qflag, Qflag;
enum bool oflag_specified, qflag, Qflag, some_input_files;

progname = argv[0];
arch_name = NULL;
Expand All @@ -49,6 +49,7 @@ char **envp)
oflag_specified = FALSE;
qflag = FALSE;
Qflag = FALSE;
some_input_files = FALSE;
/*
* Construct the prefix to the assembler driver.
*/
Expand Down Expand Up @@ -80,7 +81,12 @@ char **envp)
* grouped with other flags (so "-a-" is not the same as "-a --").
*/
if(argv[i][0] == '-' &&
!(argv[i][1] == '-' && argv[i][2] == '0')){
!(argv[i][1] == '-' && argv[i][2] == '\0')){
/*
* Treat a single "-" as reading from stdin input also.
*/
if(argv[i][1] == '\0')
some_input_files = TRUE;
/*
* the assembler allows single letter flags to be grouped
* together so "-abc" is the same as "-a -b -c". So that
Expand All @@ -107,8 +113,18 @@ char **envp)
case 'I': /* -I directory */
case 'm': /* -mc68000, -mc68010 and mc68020 */
case 'N': /* -NEXTSTEP-deployment-target */
/*
* We want to skip the next argv if the value is not
* contained in this argv eg: -I dir .
*/
if(p[1] == '\0')
i++;
/*
* And in case the value is contained in this argv
* (eg: -Idir), skip the rest.
*/
while(p[1])
p++;
p = " "; /* Finished with this arg. */
break;
case 'g':
Expand Down Expand Up @@ -169,6 +185,9 @@ char **envp)
}
}
}
else{
some_input_files = TRUE;
}
}

/*
Expand Down Expand Up @@ -251,16 +270,20 @@ char **envp)
run_clang = 1;
}

#ifdef notyet
#if 0
/*
* See rdar://9801003 where this will be changed before before NMOs and NMiOS.
*/
/*
* Use the x86 LLVM assembler as the default via running clang.
* That is after rdar://11139995 "Qualify as(1) using the x86 LLVM
* assembler as the default" is done.
* Use the LLVM integrated assembler as the default with the as(1)
* driver for Intel (64-bit & 32-bit) as well as ARM for 32-bit too
* (64-bit ARM handled above) via running clang.
*/
if(arch_flag.cputype == CPU_TYPE_X86_64 ||
arch_flag.cputype == CPU_TYPE_I386)
arch_flag.cputype == CPU_TYPE_I386 ||
arch_flag.cputype == CPU_TYPE_ARM)
run_clang = 1;
#endif /* notyet */
#endif

/*
* Use the clang as the assembler if is the default or asked to with
Expand All @@ -277,15 +300,40 @@ char **envp)
printf("%s: assembler (%s) not installed\n", progname, as);
exit(1);
}
new_argv = allocate((argc + 5) * sizeof(char *));
new_argv = allocate((argc + 8) * sizeof(char *));
new_argv[0] = as;
j = 1;
/*
* Add "-x assembler" in case the input does not end in .s this must
* come before "-" or the clang driver will issue an error:
* "error: -E or -x required when input is from standard input"
*/
new_argv[j] = "-x";
j++;
new_argv[j] = "assembler";
j++;
/*
* If we have not seen some some_input_files or a "-" or "--" to
* indicate we are assembling stdin add a "-" so clang will
* assemble stdin as as(1) would.
*/
if(some_input_files == FALSE){
new_argv[j] = "-";
j++;
}
for(i = 1; i < argc; i++){
/*
* Translate as(1) use of "--" for stdin to clang's use of "-".
*/
if(strcmp(argv[i], "--") == 0){
new_argv[j] = "-";
j++;
}
/*
* Do not pass command line argument that are Unknown to
* to clang.
*/
if(strcmp(argv[i], "-V") != 0 &&
else if(strcmp(argv[i], "-V") != 0 &&
strcmp(argv[i], "-q") != 0 &&
strcmp(argv[i], "-Q") != 0){
new_argv[j] = argv[i];
Expand Down
8 changes: 8 additions & 0 deletions as/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -5034,6 +5034,7 @@ uintptr_t value)

/* Return the size of a LEB128 value. */

#ifndef ARCH64
static inline int
sizeof_sleb128_32 (int32_t value)
{
Expand All @@ -5054,7 +5055,9 @@ sizeof_sleb128_32 (int32_t value)

return size;
}
#endif /* !defined(ARCH64) */

#ifdef ARCH64
static inline int
sizeof_sleb128_64 (int64_t value)
{
Expand All @@ -5075,7 +5078,9 @@ sizeof_sleb128_64 (int64_t value)

return size;
}
#endif /* ARCH64 */

#ifndef ARCH64
static inline int
sizeof_uleb128_32 (uint32_t value)
{
Expand All @@ -5092,7 +5097,9 @@ sizeof_uleb128_32 (uint32_t value)

return size;
}
#endif /* !defined(ARCH64) */

#ifdef ARCH64
static inline int
sizeof_uleb128_64 (uint64_t value)
{
Expand All @@ -5109,6 +5116,7 @@ sizeof_uleb128_64 (uint64_t value)

return size;
}
#endif /* ARCH64 */

#ifdef ARCH64
int
Expand Down
11 changes: 8 additions & 3 deletions cbtlibs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ OFLAG = -Os
ifneq "" "$(SDKROOT)"
SDK = -isysroot $(SDKROOT)
CC = $(shell xcrun -find -sdk $(SDKROOT) cc)
LIBTOOL = $(shell xcrun -find -sdk $(SDKROOT) libtool)
RANLIB = $(shell xcrun -find -sdk $(SDKROOT) ranlib)
else
LIBTOOL = libtool
RANLIB = ranlib
endif

CFLAGS = $(OFLAG) -g -I$(SRCROOT)/../include -Wall $(SDK)
Expand All @@ -28,7 +33,7 @@ lib_ofiles: $(OFILE_DIR) $(SYMROOT) libsyminfo.a

clean shlib_clean:
-rm -r -f $(OFILE_DIRS)
-rm -f libsyminfo.a
-rm -f libsyminfo.a libsyminfo.o libsyminfo.o.tmp
-rm -r -f *dSYM

install: all
Expand All @@ -50,15 +55,15 @@ libsyminfo.a: libsyminfo.o
$(CC) $(RC_CFLAGS) -nostdlib -r \
-o $(OBJROOT)/libsyminfo.o.tmp \
libsyminfo.o $(LIBSTUFF)
libtool -static -o $(SYMROOT)/libsyminfo.a \
$(LIBTOOL) -static -o $(SYMROOT)/libsyminfo.a \
$(OBJROOT)/libsyminfo.o.tmp


lib_ofiles_install: lib_ofiles
$(MKDIRS) $(DSTROOT)$(LOCLIBDIR)
install -p -c -m 444 $(SYMROOT)/libsyminfo.a \
$(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
ranlib $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a
$(RANLIB) $(DSTROOT)$(LOCLIBDIR)/libsyminfo.a

$(OFILE_DIR) $(SYMROOT):
$(MKDIRS) $@
4 changes: 1 addition & 3 deletions include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ FILES = mach-o/ldsyms.h mach-o/reloc.h \
mach-o/dyld_debug.h mach-o/arch.h mach-o/gmon.h mach-o/ranlib.h \
mach-o/swap.h mach-o/getsect.h mach-o/i386/swap.h \
mach-o/ppc/swap.h mach-o/ppc/reloc.h mach-o/x86_64/reloc.h \
mach-o/dyld.h mach-o/dyld_gdb.h mach-o/arm/reloc.h
FILES += mach-o/arm64/reloc.h
mach-o/dyld.h mach-o/dyld_gdb.h mach-o/arm/reloc.h mach-o/arm64/reloc.h

LOCFILES = mach-o/rld_state.h mach-o/rld.h mach-o/sarld.h mach-o/kld.h \
mach-o/redo_prebinding.h \
Expand Down Expand Up @@ -142,7 +141,6 @@ common_install:
cd mach-o/arm64; \
install -c -m 444 ${IFLAGS} reloc.h \
${DSTROOT}${$(RC_OS)_INCDIR}/mach-o/arm64

cd mach-o/m68k; \
install -c -m 444 ${IFLAGS} swap.h \
${DSTROOT}${$(RC_OS)_LOCINCDIR}/mach-o/m68k
Expand Down
20 changes: 20 additions & 0 deletions include/llvm-c/Disassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001
/* The input reference is from an ARM64::ADDXri instruction. */
#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002
/* The input reference is from an ARM64::LDRXui instruction. */
#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003
/* The input reference is from an ARM64::LDRXl instruction. */
#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004
/* The input reference is from an ARM64::ADR instruction. */
#define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005

/* The output reference is to as symbol stub. */
#define LLVMDisassembler_ReferenceType_Out_SymbolStub 1
Expand All @@ -144,6 +150,20 @@ typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
/* The output reference is to a cstring address in a literal pool. */
#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3

/* The output reference is to a Objective-C CoreFoundation string. */
#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref 4
/* The output reference is to a Objective-C message. */
#define LLVMDisassembler_ReferenceType_Out_Objc_Message 5
/* The output reference is to a Objective-C message ref. */
#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref 6
/* The output reference is to a Objective-C selector ref. */
#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref 7
/* The output reference is to a Objective-C class ref. */
#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8

/* The output reference is to a C++ symbol name. */
#define LLVMDisassembler_ReferenceType_DeMangled_Name 9

#ifdef __cplusplus
extern "C" {
#endif /* !defined(__cplusplus) */
Expand Down
Loading

0 comments on commit 69dfa55

Please sign in to comment.