Initial port to Meson - needs doc update

dlmalloc
alexis 2022-04-02 12:53:52 -06:00
parent ee6c6e642e
commit 68ed5d336f
25 changed files with 360 additions and 327 deletions

2
.gitignore vendored
View File

@ -10,7 +10,7 @@ dex_builder
dll_*/*.DLL
exe_*/*.EXE
*/build
build
# Ignore list for: kicad
*.bck

View File

@ -1,68 +0,0 @@
# Main A6 makefile. Running 'make' here will build all the executable files,
# but not assemble them into any superfs. To build a superfs as well, you can
# specify any of the targets shown below in the TARGETS variable. You may also
# find the user variables from the toolchain build system useful:
#
# CROSS_COMPILE If your compiler isn't named as we assume, set this
# in the usual way (e.g. for m68k-elf-gcc use
# TARGET=m68k-elf-)
#
# NOSTRIP If defined and not empty, the executables are not
# stripped. This makes the superfs huge but helps with
# asm-level debugging.
#
# MOUNT If defined and not empty, the superfs is mounted
# in a subdirectory so you can look around inside.
#
# There may be more; see toolchain/a6_inc.mk
#
# Other useful targets:
#
# clean Remove intermediate targets like object files.
# mrproper Remove everything that was built, including outputs.
TARGETS := icm68k
LIB_FILES := a_runtime/libruntime.a exe_a6/A6.EXE dll_system/SYSTEM.DLL
DB := dll_ld/dex_builder
A6_ROOT := $(CURDIR)
SRECS := $(patsubst %,superfs_%.srec,${TARGETS})
LIBS := $(dir ${LIB_FILES})
export A6_ROOT
.PHONY: all clean icm68k libs
all: libs
${DB}:
${MAKE} -C dll_ld -f Makefile-dex
libs:
for i in ${LIBS}; do ${MAKE} -C $${i} || break; done
${LIB_FILES}: libs
define make-build-target
$1: superfs_$1.srec
endef
$(foreach i,${TARGETS},$(eval $(call make-build-target,${i})))
%.srec: % ${DB} ${LIB_FILES}
PYTHONPATH=toolchain python3 -m superfs_builder --db ${DB} $< -vt $@
ifneq ($(strip ${MOUNT}),)
srec_cat $@ -output $@.img -binary
[ -d $@.fs ] && sudo umount ./$@.fs || return 0
mkdir -p $@.fs
sudo mount -o loop,ro -t msdos $@.img $@.fs
rm $@.img
endif
clean:
for i in ${LIBS}; do ${MAKE} -C $${i} clean; done
make -C dll_ld -f Makefile-dex clean
mrproper:
for i in ${LIBS}; do ${MAKE} -C $${i} mrproper; done
make -C dll_ld -f Makefile-dex mrproper
rm -f ${SRECS}

8
a_runtime/meson.build Normal file
View File

@ -0,0 +1,8 @@
a_runtime = static_library(
'runtime',
'runtime.c',
include_directories: inc,
link_args: link_args,
link_depends: link_depends,
pic: false,
)

30
cross.ini Normal file
View File

@ -0,0 +1,30 @@
[properties]
sizeof_int = 4
sizeof_wchar_t = 4
sizeof_void* = 4
alignment_char = 1
alignment_void* = 2
alignment_double = 2
has_function_printf = false
linker_paths = ['.']
linker_script = 'toolchain/a6.ld'
[constants]
arch = 'm68k-elf'
[host_machine]
system = ''
cpu_family = 'm68k'
cpu = '68010'
endian = 'big'
[binaries]
c = arch + '-gcc'
strip = arch + '-strip'
[built-in options]
c_args = ['-D__A6__=1', '-mcpu=68010']
c_link_args = ['-fvisibility=hidden', '-static', '-ffreestanding', '-nostdlib', '-Wl,-r']

View File

@ -1,6 +0,0 @@
NAME := LD
FORMAT := DLL
SRCS := avl68kos_ld.c
include ${A6_ROOT}/toolchain/a6_inc.mk
CFLAGS += -O2 -ggdb

View File

@ -1,21 +0,0 @@
BUILD_DIR := build-dex
OBJECTS := ${BUILD_DIR}/avl68kos_ld.o
.PHONY: dex_builder clean
CFLAGS ?= -O0 -ggdb -DAVL68KOS_VERBOSE=1 -I../include
dex_builder: dex_builder.c ${OBJECTS}
${CC} -o $@ ${CFLAGS} $^
clean:
rm -f ${OBJECTS}
rm -rf ${BUILD_DIR}
mrproper: clean
rm -f dex_builder
${BUILD_DIR}/%.o: %.c
@mkdir -p $$(dirname $@)
${CC} -c ${CFLAGS} $^ -o $@

20
dll_ld/meson.build Normal file
View File

@ -0,0 +1,20 @@
dex_builder = executable(
'dex_builder',
'dex_builder.c', 'avl68kos_ld.c',
c_args: '-DAVL68KOS_VERBOSE=1',
native: true,
include_directories: inc_native,
)
dll_ld = executable(
'LD.DLL',
'avl68kos_ld.c',
include_directories: inc,
link_args: link_args,
link_depends: link_depends,
link_with: link_with,
link_whole: link_whole,
export_dynamic: true,
)

View File

@ -1,16 +0,0 @@
NAME := SYSTEM
FORMAT := DLL
SRCS+= dbgcon/dbgcon.c
SRCS+= pthread/mutex.c
SRCS+= dlist.c
SRCS+= kernel.c
SRCS+= a6signal.s
include newlib/Makefile.inc
include alloc/Makefile.inc
include ${A6_ROOT}/toolchain/a6_inc.mk
CFLAGS += -O2 -ggdb
# Naughty newlib...
WARNFLAGS = -Wno-sign-compare -Wno-char-subscripts -Wno-missing-field-initializers

View File

@ -1 +0,0 @@
SRCS+= alloc/malloc.c

104
dll_system/meson.build Normal file
View File

@ -0,0 +1,104 @@
dll_system = executable(
'SYSTEM.DLL',
'alloc/malloc.c',
'dbgcon/dbgcon.c',
'dlist.c',
'kernel.c',
'pthread/mutex.c',
'a6signal.S',
'newlib/machine/m68k/memcpy.S',
'newlib/machine/m68k/memset.S',
'newlib/machine/m68k/setjmp.S',
'newlib/machine/m68k/strcpy.c',
'newlib/machine/m68k/strlen.c',
'newlib/misc/__dprintf.c',
'newlib/misc/ffs.c',
'newlib/misc/unctrl.c',
# 'newlib/misc/init.c', TODO @22022021 - make sure this links right
# 'newlib/misc/fini.c', TODO @22022021 - make sure this links right
# 'newlib/string/bcmp.c', DEPRECATED
# 'newlib/string/bcopy.c', DEPRECATED
# 'newlib/string/bzero.c', DEPRECATED
'newlib/string/ffsl.c',
'newlib/string/ffsll.c',
'newlib/string/fls.c',
'newlib/string/flsl.c',
'newlib/string/flsll.c',
# 'newlib/string/index.c', LEGACY
'newlib/string/memccpy.c',
'newlib/string/memchr.c',
'newlib/string/memcmp.c',
# 'newlib/string/memcpy.c', PROVIDED MACHINE SPECIFIC
'newlib/string/memmem.c',
'newlib/string/memmove.c',
'newlib/string/mempcpy.c',
'newlib/string/memrchr.c',
# 'newlib/string/memset.c', PROVIDED MACHINE SPECIFIC
'newlib/string/rawmemchr.c',
'newlib/string/rindex.c',
'newlib/string/stpcpy.c',
'newlib/string/stpncpy.c',
'newlib/string/strcasecmp.c',
'newlib/string/strcasestr.c',
'newlib/string/strcat.c',
'newlib/string/strchr.c',
'newlib/string/strchrnul.c',
'newlib/string/strcmp.c',
'newlib/string/strcoll.c',
# 'newlib/string/strcpy.c', PROVIDED MACHINE SPECIFIC
'newlib/string/strcspn.c',
# 'newlib/string/strdup.c', TODO @22022021 MALLOC
# 'newlib/string/strdup_r.c', TODO @22022021 MALLOC
'newlib/string/strerror.c',
'newlib/string/strerror_r.c',
'newlib/string/strlcat.c',
'newlib/string/strlcpy.c',
# 'newlib/string/strlen.c', PROVIDED MACHINE SPECIFIC
'newlib/string/strlwr.c',
'newlib/string/strncasecmp.c',
'newlib/string/strncat.c',
'newlib/string/strncmp.c',
'newlib/string/strncpy.c',
# 'newlib/string/strndup.c', TODO @22022021 MALLOC
'newlib/string/strnlen.c',
'newlib/string/strnstr.c',
'newlib/string/strpbrk.c',
'newlib/string/strrchr.c',
'newlib/string/strsep.c',
'newlib/string/strspn.c',
'newlib/string/strstr.c',
'newlib/string/strtok.c',
'newlib/string/strtok_r.c',
'newlib/string/strupr.c',
'newlib/string/strverscmp.c',
'newlib/string/strxfrm.c',
'newlib/string/swab.c',
'newlib/string/u_strerr.c', # TODO - provide this to define custom errs
'newlib/ctype/ctype_.c',
'newlib/ctype/isalnum.c',
'newlib/ctype/isalpha.c',
'newlib/ctype/iscntrl.c',
'newlib/ctype/isdigit.c',
'newlib/ctype/islower.c',
'newlib/ctype/isupper.c',
'newlib/ctype/isprint.c',
'newlib/ctype/ispunct.c',
'newlib/ctype/isspace.c',
'newlib/ctype/isxdigit.c',
'newlib/ctype/tolower.c',
'newlib/ctype/toupper.c',
'newlib/reent/impure.c',
c_args: ['-D__A6__=1', '-DREENTRANT_SYSCALLS_PROVIDED'],
include_directories: inc,
link_args: link_args,
link_depends: link_depends,
link_with: link_with,
link_whole: link_whole,
export_dynamic: true,
)

View File

@ -1,42 +0,0 @@
NAME := A6
FORMAT := EXE
INCLUDES += include
CFLAGS += -O2 -ggdb
SRCS += main.c
SRCS += vectors.c
SRCS += vec_wrapper.s
SRCS += mpu.c
SRCS += syscall.c
SRCS += procmm.c
SRCS += kpalloc.c
SRCS += stacks.c
SRCS += concur.c
SRCS += sched/lists.c
SRCS += sched/pids.c
SRCS += sched/sched.c
SRCS += sched/process.c
SRCS += sched/thread.c
SRCS += sched/signal.c
SRCS += sched/resources.c
SRCS += sched/entry.s
SRCS += io/tmpfs.c
SRCS += io/kio.c
EXTRA_DEP_SRCS += asm/entry_exports.c
GENS += ${BUILD_DIR}/asm/entry_exports.inc
INCLUDES += ${BUILD_DIR}
include kinfo/Makefile.inc
include ${A6_ROOT}/toolchain/a6_inc.mk
build/asm/entry_exports.inc: asm/entry_exports.c
@echo "GEN " $<
@mkdir -p build/asm
@${CC} $(filter-out -flto,${CFLAGS}) -S -o $@.s $<
@echo "// Autogenerated from $<" > $@
@grep '\s\+#define' $@.s | sed -e 's/\s\+//' -e 's/ #/ /' >> $@
@rm $@.s

View File

@ -0,0 +1,39 @@
#!/usr/bin/python3
"""gen_entry_exports.py SOURCE.S OUT.INC
Process a compiler-generated assembly file into an include header, filtering
out only lines containing #define. This allows you to export C-environment
information by writing #define in an asm volatile block.
SOURCE.S may also be an ar archive containing just SOURCE.S - this is for
compatibility with Meson (or at least, the probably dumb way I'm doing this in
Meson).
"""
import os
import re
import subprocess
import sys
import tempfile
NUMERIC_DEF_RE = re.compile("^#define (\w+) #?([-0-9]+)$")
if len(sys.argv) < 3:
print(__doc__, file=sys.stderr)
sys.exit()
sourcefn = sys.argv[1]
outfn = sys.argv[2]
with open(sourcefn, "r") as f_in:
with open(outfn, "w") as f_out:
print("// Autogenerated from", sourcefn, file=f_out)
for line in f_in:
line = line.strip()
m = NUMERIC_DEF_RE.match(line)
if m:
line = "#define " + m.group(1) + " " + m.group(2)
if line.startswith("#define"):
print(line, file=f_out)

View File

@ -1 +0,0 @@
SRCS+= kinfo/kinfo.c

53
exe_a6/meson.build Normal file
View File

@ -0,0 +1,53 @@
fs = import('fs')
prog_python = import('python').find_installation('python3')
entry_exports_intermed = static_library(
'entry_exports',
'asm/entry_exports.c',
c_args: ['-S'],
name_prefix: '',
name_suffix: 's.a',
include_directories: [inc, 'include'],
)
entry_exports_inc = custom_target(
'entry_exports.asm.h',
output: 'entry_exports.asm.h',
input: ['gen_entry_exports.py', entry_exports_intermed],
command: [prog_python, '@INPUT@', '@OUTPUT@'],
)
exe_a6 = executable(
'A6.EXE',
'main.c',
'vectors.c',
'vec_wrapper.S',
'mpu.c',
'syscall.c',
'procmm.c',
'kpalloc.c',
'stacks.c',
'concur.c',
'sched/lists.c',
'sched/pids.c',
'sched/sched.c',
'sched/process.c',
'sched/thread.c',
'sched/signal.c',
'sched/resources.c',
'sched/entry.S',
'io/tmpfs.c',
'io/kio.c',
'kinfo/kinfo.c',
entry_exports_inc,
include_directories: [inc, 'include'],
link_args: link_args,
link_depends: link_depends,
link_with: link_with,
link_whole: link_whole,
)

View File

@ -1,6 +1,6 @@
// intellectual property is bullshit bgdc
#include "asm/entry_exports.inc"
#include "entry_exports.asm.h"
.extern a6_current_tcb
.extern a6_scheduler_stack

64
meson.build Normal file
View File

@ -0,0 +1,64 @@
project('a6', 'c')
python = import('python')
keyval = import('keyval')
prog_python = python.find_installation('python3')
link_args = []
link_depends = []
link_with = []
link_whole = []
foreach entry : meson.get_external_property('linker_paths', [''])
if entry != ''
link_args += '-L' + meson.source_root() / entry
endif
endforeach
linker_script = meson.get_external_property('linker_script', '')
if linker_script != ''
link_args += '-T' + linker_script
link_depends += meson.source_root() / linker_script
endif
gcc_info_fn = meson.build_root() / 'gcc_info.txt'
gcc_info_r = run_command(prog_python, 'toolchain/gcc_info.py',
meson.get_compiler('c').cmd_array()[-1],
gcc_info_fn
)
gcc_info = keyval.load(gcc_info_fn)
link_args += gcc_info['LIBGCC_A']
inc_native = include_directories('include')
inc = include_directories('include', 'includesys')
add_project_arguments('-O2', '-ggdb', language: 'c')
subdir('a_runtime')
link_whole += a_runtime
subdir('dll_system')
link_with += dll_system
subdir('dll_ld')
link_with += dll_ld
subdir('exe_a6')
strip = find_program('strip', required: true)
board = get_option('board')
srec_fn = 'superfs_' + board + '.srec'
superfs_srec = custom_target(
srec_fn,
output: srec_fn,
input: [dll_system, dll_ld, exe_a6, 'superfs_' + board + '/SUPERFS.INI'],
command: [
prog_python,
'@SOURCE_ROOT@/toolchain/run_superfs_builder.py',
'--db', dex_builder.full_path(),
'--strip', strip.full_path(),
'@SOURCE_ROOT@/superfs_' + board,
'-t',
'@OUTPUT@',
],
build_always: true,
)

4
meson_options.txt Normal file
View File

@ -0,0 +1,4 @@
option('board', type: 'string', value: 'icm68k',
description: 'Name of the board whose superfs should be built. ' +
'For a given BOARD, there must be a superfs_BOARD directory.'
)

View File

@ -1 +1 @@
../exe_a6/A6.EXE
../build/exe_a6/A6.EXE

View File

@ -6,9 +6,9 @@ label = ICM68K
[files]
*.DLL = contig dex order=2 export !export=_*start
*.DRV = contig dex order=3
*.EXE = contig dex order=3 !export=_*start
*.DLL = contig dex strip order=2 export !export=_*start
*.DRV = contig dex strip order=3
*.EXE = contig dex strip order=3 !export=_*start
SYSTEM.DLL = align=2048 order=1 alias=_dllstart:system_dllstart
A6.EXE = entry=_exestart order=2

View File

@ -1 +1 @@
../dll_system/SYSTEM.DLL
../build/dll_system/SYSTEM.DLL

View File

@ -1,165 +0,0 @@
###############################################################################
# Main A6 build script
#
# This GNU Make include file is meant to be included at the bottom of the
# makefile for each build target (note that each target should get its own
# makefile). In general, the preceding text will be entirely or mostly variable
# definitions. Relevant variables for this script are:
#
# (User/environment)
# CROSS_COMPILE If your compiler isn't called m68k-elf-gcc, set this.
# NOSTRIP Don't strip symbols after linking
#
# (Normally used)
# NAME Base name (without extension) of the build target
# FORMAT Format and extension of the build target (EXE, DLL, a)
# SRCS List of all source files to be built
#
# (Less commonly used)
# CFLAGS Additional C flags
# CSTDFLAGS C language/standard flags
# EXTRA_DEP_SRCS Source to compute dependencies for, but not
# automatically build. Typically used when you specify
# your own build rules for one file.
# GENS List of generated targets. They will be added as
# dependencies to the final build; you must write a
# rule to specify how to build them.
# INCLUDES Additional includes beyond the defaults
# WARNFLAGS Replacement warning flags, instead of -Werror.
# DEFAULT_WARNFLAGS will still be appended to this.
#
# (Rarely used)
# DEFAULT_DEFFLAGS Default definition flags appended to your flags. Only
# change if you REALLY know what you're doing...
# DEFAULT_WARNFLAGS Default warning flags appended to your flags. Note
# -Werror is not in here - override that with just
# WARNFLAGS.
# MACHFLAGS Machine configuration flags
TOOLCHAIN := ${A6_ROOT}/toolchain
INCLUDES += ${A6_ROOT}/include ${A6_ROOT}/includesys
BUILD_DIR := build
DEFAULT_WARNFLAGS ?= -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable
DEFAULT_DEFFLAGS ?= -D__A6__=1
MACHFLAGS ?= -mcpu=68010
CSTDFLAGS ?= -std=gnu11
CROSS_COMPILE ?= m68k-elf-
CC := ${CROSS_COMPILE}gcc
CXX := ${CROSS_COMPILE}g++
STRIP := ${CROSS_COMPILE}strip
OBJDUMP := ${CROSS_COMPILE}objdump
OBJCOPY := ${CROSS_COMPILE}objcopy
ifeq (${FORMAT},a)
OUTPUT := lib${NAME}.${FORMAT}
else
OUTPUT := ${NAME}.${FORMAT}
endif
include ${BUILD_DIR}/gcc_info.mk
# The use of -static with -Wl,-r gets us what we want for now. If we have to
# move to -shared, this produces a program header (Phdr) section in the ELF,
# we'll have to teach the linker how to handle that.
WARNFLAGS ?= -Werror
WARNFLAGS += ${DEFAULT_WARNFLAGS}
DEFFLAGS += ${DEFAULT_DEFFLAGS}
INCFLAGS ?= $(patsubst %,-I%,${INCLUDES})
CFLAGS += ${MACHFLAGS} ${INCFLAGS} ${WARNFLAGS} ${DEFFLAGS} ${CSTDFLAGS}
LINKFLAGS += -static -ffreestanding -nostdlib -Wl,-T ${TOOLCHAIN}/a6.ld -Wl,-r
DLLFLAGS += ${LINKFLAGS}
DLLDEPS += -L../a_runtime -u _dllstart -lruntime ${LIBGCC_A}
EXEFLAGS += ${LINKFLAGS} -Wl,--gc-sections
EXEDEPS += -L../a_runtime -u _exestart -lruntime ${LIBGCC_A}
STRIPFLAGS ?= -g -R.comment
objs := $(patsubst %.cpp,${BUILD_DIR}/%.o,${SRCS})
objs := $(patsubst %.c,${BUILD_DIR}/%.o,${objs})
objs := $(patsubst %.s,${BUILD_DIR}/%.o,${objs})
objs := $(patsubst %.S,${BUILD_DIR}/%.o,${objs})
OBJS += ${objs}
deps := $(patsubst %.cpp,${BUILD_DIR}/%.d,${SRCS} ${EXTRA_DEP_SRCS})
deps := $(patsubst %.c,${BUILD_DIR}/%.d,${deps})
deps := $(filter-out %.s,${deps})
deps := $(filter-out %.S,${deps})
DEPS += ${deps}
.PHONY: clean all
all: ${OUTPUT}
ifeq ($(strip $(filter clean mrproper,${MAKECMDGOALS})),)
NODEP := 0
else
NODEP := 1
endif
ifeq (${NODEP},0)
-include ${DEPS}
endif
${BUILD_DIR}/gcc_info.mk: ${TOOLCHAIN}/gcc_info.py
@mkdir -p ${BUILD_DIR}
@${TOOLCHAIN}/gcc_info.py ${CC} $@
${BUILD_DIR}/%.d: %.cpp
@mkdir -p $$(dirname $@)
@echo "DEP " $<
@${CXX} -MM ${CXXFLAGS} $< -c -o $@ ${GCC_FORMAT} && \
sed -i -e "1s,^,$$(dirname $@)/," $@
${BUILD_DIR}/%.d: %.c
@mkdir -p $$(dirname $@)
@echo "DEP " $<
@${CC} -MM ${CFLAGS} $< -c -o $@ ${GCC_FORMAT} && \
sed -i -e "1s,^,${BUILD_DIR}/," $@
${BUILD_DIR}/%.o: %.cpp ${GENS}
@mkdir -p $$(dirname $@)
@echo "CXX " $<
@${CXX} ${CXXFLAGS} -c -o $@ $<
${BUILD_DIR}/%.o: %.c ${GENS}
@mkdir -p $$(dirname $@)
@echo "CC " $<
@${CC} ${CFLAGS} -c -o $@ $<
${BUILD_DIR}/%.o: %.s ${GENS}
@mkdir -p $$(dirname $@)
@echo "CCasm" $<
@${CC} ${CFLAGS} -x assembler-with-cpp -c -o $@ $<
${BUILD_DIR}/%.o: %.S ${GENS}
@mkdir -p $$(dirname $@)
@echo "CCasm" $<
@${CC} ${CFLAGS} -x assembler-with-cpp -c -o $@ $<
${NAME}.DLL ${NAME}.EXE: ${OBJS}
@echo "LINK " $@ "<=" $<
@${CC} ${CFLAGS} ${DLLFLAGS} -o $@ $^ ${DLLDEPS}
ifeq ($(strip ${NOSTRIP}),)
@echo "STRIP" $@
@${STRIP} ${STRIPFLAGS} $@
endif
lib${NAME}.a: ${OBJS}
@echo "AR " $@ "<=" $<
@ar rcs $@ $<
clean:
@echo "RM ${BUILD_DIR}/**/*.o"
@rm -f ${OBJS}
@echo "RM ${BUILD_DIR}/**/*.d"
@rm -f ${DEPS}
@echo "RM ${BUILD_DIR}"
@rm -rf ${BUILD_DIR}
mrproper: clean
@echo "RM ${OUTPUT}"
@rm -f ${OUTPUT}

View File

@ -0,0 +1,4 @@
#!/usr/bin/python3
# This just gets around some PYTHONPATH awkwardness with Meson.
import superfs_builder.superfs_builder
superfs_builder.superfs_builder.main()

View File

@ -111,6 +111,7 @@ class Entry:
self.align = 0
self.alignpad = True
self.dex = False
self.strip = False
self.order = 0xFFFFFFFF
self.export = [(False, "*")]
self.alias = []
@ -175,6 +176,8 @@ class Entry:
self.alignpad = pol
elif directive == "dex":
self.dex = pol
elif directive == "strip":
self.strip = pol
elif directive == "order":
self.order = int(argument, 0) if pol else 0xFFFFFFFF
elif directive == "export":
@ -208,6 +211,8 @@ class Entry:
prop_strings.append("!alignpad")
if self.dex:
prop_strings.append("dex")
if self.strip:
prop_strings.append("strip")
if self.order != 0xFFFFFFFF:
prop_strings.append(f"order={self.order}")
for pol, glob in self.export[1:]:
@ -332,6 +337,25 @@ def print_usage_summary(fs):
print(f"{summary2:<62}")
print(f"╘════════════════════════════════════════════════════════════════╛")
def do_strip(code, strip):
"""Strip a binary before installing it.
code: code to strip
strip: path to the strip tool
returns the stripped code.
"""
fd, objtemp = tempfile.mkstemp(".o")
f = os.fdopen(fd, "wb")
f.write(code)
f.close()
subprocess.run([strip, "-g", "-R.comment", objtemp], check=True)
with open(objtemp, "rb") as f:
return f.read()
#==============================================================================
# let's gooooooooo
@ -343,6 +367,7 @@ def main():
ap.add_argument("dest", type=str, help="destination image file")
ap.add_argument("--db", type=str, help="path to dex_builder",
default="./built/dex_builder")
ap.add_argument("--strip", type=str, help="path to strip")
ap.add_argument("-v", action="count", help="talk a lot", default=0)
ap.add_argument("-t", action="store_true",
help="truncate image to minimum size")
@ -478,6 +503,8 @@ def main():
i.origsize = len(i.data)
if i.compress:
i.data = zlib.compress(i.data)
if i.strip:
i.data = do_strip(i.data, args.strip)
i.size = len(i.data)
#--------------------------------------------------------------------------