Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ ld64-*
zPATCHES
cctools-*
libtapi*
build/*
*.xcuserstate
*.xcuserdatad
*/xcuserdata/*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libyaml"]
path = libyaml
url = https://github.com/yaml/libyaml/
25 changes: 21 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Top Level CMake file for XTOOLS.

cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.9.6)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to MinSizeRel")
Expand Down Expand Up @@ -64,7 +64,10 @@ else()
message(STATUS "*Top Level* NO LTO")
endif()

if(XTOOLS_TAPI_PATH AND
if(XTOOLS_USE_TAPILITE)
option(XTOOLS_TAPI_SUPPORT "Support TAPI in ld64." ON)
message(STATUS "*Top Level* WITH TAPIlite")
elseif(XTOOLS_TAPI_PATH AND
EXISTS ${XTOOLS_TAPI_PATH}/include/tapi AND
EXISTS ${XTOOLS_TAPI_PATH}/lib/libtapi.dylib)
configure_file(
Expand Down Expand Up @@ -128,8 +131,13 @@ include_directories(BEFORE SYSTEM "${CMAKE_SOURCE_DIR}/macho-target-includes")
include_directories(BEFORE SYSTEM "${CMAKE_BINARY_DIR}/include")
include_directories(BEFORE SYSTEM "${CMAKE_BINARY_DIR}/host-includes")
if(XTOOLS_TAPI_SUPPORT)
include_directories(BEFORE SYSTEM "${XTOOLS_TAPI_PATH}/include")
message(STATUS "*Top Level* including ${XTOOLS_TAPI_PATH}/include")
if(XTOOLS_USE_TAPILITE)
include_directories(BEFORE SYSTEM "${CMAKE_SOURCE_DIR}/tapilite/include")
message(STATUS "*Top Level* including ${CMAKE_SOURCE_DIR}/tapilite/include")
else()
include_directories(BEFORE SYSTEM "${XTOOLS_TAPI_PATH}/include")
message(STATUS "*Top Level* including ${XTOOLS_TAPI_PATH}/include")
endif()
endif()

if (EXISTS ${CMAKE_BINARY_DIR}/lib)
Expand Down Expand Up @@ -160,6 +168,15 @@ if (NOT XTOOLS_HAS_MODERNXAR)
COPYONLY)
endif()

# build tapilite first, so ld64 can link against it
if(XTOOLS_USE_TAPILITE)
if(EXISTS ${XTOOLS_LIBYAML_PATH}/CMakeLists.txt)
add_subdirectory(${XTOOLS_LIBYAML_PATH})
include_directories("${CMAKE_SOURCE_DIR}/libyaml/include")
endif ()
add_subdirectory(tapilite)
endif()

# Evaluate first so that we find out about libprunetrie.
if( EXISTS ${CMAKE_SOURCE_DIR}/ld64/CMakeLists.txt )
add_subdirectory(ld64)
Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/append.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ static char rcsid[] = "$OpenBSD: append.c,v 1.2 1996/06/26 05:31:16 deraadt Exp
* Append files to the archive - modifies original archive or creates
* a new archive if named archive does not exist.
*/
int
append(argv)
char **argv;
int
append (char **argv)
{
int afd, fd, eval;
char *file;
Expand Down
11 changes: 4 additions & 7 deletions cctools/ar/ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ extern char support_url[];
* functions. Some hacks that let us be backward compatible with 4.3 ar
* option parsing and sanity checking.
*/
int
main(argc, argv)
int argc;
char **argv;
int
main (int argc, char **argv)
{
int c, retval, verbose, run_ranlib, toc64;
char *p;
Expand Down Expand Up @@ -317,9 +315,8 @@ main(argc, argv)
exit(EXIT_SUCCESS);
}

static void
badoptions(arg)
char *arg;
static void
badoptions (char *arg)
{

warnx("illegal option combination for %s", arg);
Expand Down
28 changes: 10 additions & 18 deletions cctools/ar/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ static char hb[sizeof(HDR) + 1]; /* real header */

int archive_opened_for_writing = 0;

int
open_archive(mode)
int mode;
int
open_archive (int mode)
{
int created, fd, nr, r;
char buf[SARMAG];
Expand Down Expand Up @@ -207,9 +206,8 @@ open_archive(mode)
return (fd);
}

void
close_archive(fd)
int fd;
void
close_archive (int fd)
{

(void)close(fd); /* Implicit unlock. */
Expand All @@ -226,9 +224,8 @@ close_archive(fd)
* get_arobj --
* read the archive header for this member
*/
int
get_arobj(fd)
int fd;
int
get_arobj (int fd)
{
struct ar_hdr *hdr;
int len, nr;
Expand Down Expand Up @@ -295,9 +292,7 @@ static int already_written;
* Write an archive member to a file.
*/
void
put_arobj(cfp, sb)
CF *cfp;
struct stat *sb;
put_arobj(CF *cfp, struct stat *sb)
{
unsigned int lname;
char *name;
Expand Down Expand Up @@ -401,9 +396,7 @@ put_arobj(cfp, sb)
* have been ripped out long ago.
*/
void
copy_ar(cfp, size)
CF *cfp;
off_t size;
copy_ar(CF *cfp, off_t size)
{
static char pad = '\n';
off_t sz;
Expand Down Expand Up @@ -445,9 +438,8 @@ copy_ar(cfp, size)
* skip_arobj -
* Skip over an object -- taking care to skip the pad bytes.
*/
void
skip_arobj(fd)
int fd;
void
skip_arobj (int fd)
{
off_t len;

Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/contents.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ static char rcsid[] = "$OpenBSD: contents.c,v 1.2 1996/06/26 05:31:19 deraadt Ex
* Handles t[v] option - opens the archive and then reads headers,
* skipping member contents.
*/
int
contents(argv)
char **argv;
int
contents (char **argv)
{
int afd, all;
struct tm *tp;
Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ static char rcsid[] = "$OpenBSD: delete.c,v 1.2 1996/06/26 05:31:19 deraadt Exp
* delete --
* Deletes named members from the archive.
*/
int
delete(argv)
char **argv;
int
delete (char **argv)
{
CF cf;
off_t size;
Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ static char rcsid[] = "$OpenBSD: extract.c,v 1.2 1996/06/26 05:31:20 deraadt Exp
* members date otherwise date is time of extraction. Does not modify
* archive.
*/
int
extract(argv)
char **argv;
int
extract (char **argv)
{
char *file;
int afd, all, eval, tfd;
Expand Down
29 changes: 12 additions & 17 deletions cctools/ar/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.2 1996/06/26 05:31:21 deraadt Exp $"

char *tname = "temporary file"; /* temporary file "name" */

int
tmp()
int
tmp (void)
{
extern char *envtmp;
sigset_t set, oset;
Expand Down Expand Up @@ -117,8 +117,7 @@ tmp()
* does, remove it from the argument list.
*/
char *
files(argv)
char **argv;
files (char **argv)
{
char **list, *p;

Expand All @@ -132,45 +131,41 @@ files(argv)
return (NULL);
}

void
orphans(argv)
char **argv;
void
orphans (char **argv)
{

for (; *argv; ++argv)
warnx("%s: not found in archive", *argv);
}

char *
rname(path)
char *path;
rname (char *path)
{
char *ind;

return ((ind = strrchr(path, '/')) ? ind + 1 : path);
}

int
compare(dest)
char *dest;
int
compare (char *dest)
{

if (options & AR_TR)
return (!strncmp(chdr.name, rname(dest), OLDARMAXNAME));
return (!strcmp(chdr.name, rname(dest)));
}

void
badfmt()
void
badfmt (void)
{

errno = EFTYPE;
err(1, "%s", archive);
}

void
error(name)
char *name;
void
error (char *name)
{

err(1, "%s", name);
Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ static char rcsid[] = "$OpenBSD: move.c,v 1.2 1996/06/26 05:31:21 deraadt Exp $"
* option selected members go after 'posname'. If no options, members
* are moved to end of archive.
*/
int
move(argv)
char **argv;
int
move (char **argv)
{
CF cf;
off_t size, tsize;
Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ static char rcsid[] = "$OpenBSD: print.c,v 1.2 1996/06/26 05:31:22 deraadt Exp $
* Prints archive members on stdout - if member names given only
* print those members, otherwise print all members.
*/
int
print(argv)
char **argv;
int
print (char **argv)
{
CF cf;
int afd, all;
Expand Down
5 changes: 2 additions & 3 deletions cctools/ar/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ static char rcsid[] = "$OpenBSD: replace.c,v 1.2 1996/06/26 05:31:23 deraadt Exp
* the key entry, based on the a, b and i options. If the u option
* is specified, modification dates select for replacement.
*/
int
replace(argv)
char **argv;
int
replace (char **argv)
{
char *file;
int afd, curfd, errflg, exists, mods, sfd, tfd1, tfd2;
Expand Down
12 changes: 6 additions & 6 deletions cctools/as/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ if(XTOOLS_C_HAS_WNODEPRECATED_FLAG)
endif()

add_executable(as-driver driver.c)
set_target_properties(as-driver PROPERTIES COMPILE_FLAGS "-Di486 -Di586 -Di686")
set_target_properties(as-driver PROPERTIES COMPILE_FLAGS "-Di486 -Di586 -Di686 -UPPC")
target_link_libraries(as-driver stuff)
set_target_properties(as-driver PROPERTIES OUTPUT_NAME as)
install(TARGETS as-driver DESTINATION bin )

add_executable(i386-as ${X86_SRCS})
set_target_properties(i386-as PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686")
set_target_properties(i386-as PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686 -UPPC")
set_target_properties(i386-as PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/i386)
set_target_properties(i386-as PROPERTIES OUTPUT_NAME as)
target_link_libraries(i386-as stuff)
Expand All @@ -59,13 +59,13 @@ install(TARGETS i386-as DESTINATION bin/i386)

if(BUILD_TESTING)
add_executable(test-x86 i386-check.c)
set_target_properties(test-x86 PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686")
set_target_properties(test-x86 PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686 -UPPC")
set_target_properties(test-x86 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
add_test(NAME check-x86-as COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/check-as $<TARGET_FILE:test-x86> i386 $<TARGET_FILE:as-driver>)
endif()

add_executable(x8664-as ${X86_SRCS})
set_target_properties(x8664-as PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686 -DARCH64")
set_target_properties(x8664-as PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686 -DARCH64 -UPPC")
set_target_properties(x8664-as PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/x86_64)
set_target_properties(x8664-as PROPERTIES OUTPUT_NAME as)
target_link_libraries(x8664-as stuff)
Expand All @@ -76,7 +76,7 @@ install(TARGETS x8664-as DESTINATION bin/x86_64)

if(BUILD_TESTING)
add_executable(test-x86_64 i386-check.c)
set_target_properties(test-x86_64 PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686 -DARCH64")
set_target_properties(test-x86_64 PROPERTIES COMPILE_FLAGS "-DI386 -Di486 -Di586 -Di686 -DARCH64 -UPPC")
set_target_properties(test-x86_64 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
add_test(NAME check-x86_86-as COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/check-as $<TARGET_FILE:test-x86_64> x86_64 $<TARGET_FILE:as-driver>)
endif()
Expand Down Expand Up @@ -109,7 +109,7 @@ endif()
install(TARGETS ppc64-as DESTINATION bin/ppc64)

add_executable(arm-as ${ARM_SRCS})
set_target_properties(arm-as PROPERTIES COMPILE_FLAGS "-DARM")
set_target_properties(arm-as PROPERTIES COMPILE_FLAGS "-DARM -UPPC")
set_target_properties(arm-as PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/arm)
set_target_properties(arm-as PROPERTIES OUTPUT_NAME as)
target_link_libraries(arm-as stuff)
Expand Down
4 changes: 2 additions & 2 deletions cctools/as/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ FILE *fp)
return -1;
}

int
do_scrub_next_char_from_string()
int
do_scrub_next_char_from_string (void)
{
/* State 0: beginning of normal line
1: After first whitespace on normal line (flush more white)
Expand Down
6 changes: 5 additions & 1 deletion cctools/as/as.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ extern char version_string[];
* asserts() from <assert.h> are DISabled when NDEBUG is defined and
* asserts() from <assert.h> are ENabled when NDEBUG is undefined.
* For speed NDEBUG is defined so assert()'s are left out.
* NDEBUG is also defined on the command line, though, so wrap it in a
* preprocessor conditional, to avoid -Wmacro-redefined.
#undef NDEBUG
*/
#define NDEBUG
#ifndef NDEBUG
# define NDEBUG
#endif

/*
* For speed SUSPECT is undefined.
Expand Down
Loading