From 238b3dc734b6e10fb23526bdf236d4f9d19cc3c8 Mon Sep 17 00:00:00 2001 From: ranchuan Date: Fri, 19 Apr 2024 18:56:55 +0800 Subject: [PATCH] =?UTF-8?q?make.py=20=E6=B7=BB=E5=8A=A0=E5=8F=8D=E6=B1=87?= =?UTF-8?q?=E7=BC=96=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- make.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index fbd5105..2f04255 100644 --- a/make.py +++ b/make.py @@ -23,6 +23,7 @@ AS = CC + ' -x assembler-with-cpp' HEX = 'arm-none-eabi-objcopy' + ' -O ihex' BIN = 'arm-none-eabi-objcopy' + ' -O binary -S' +OD = 'arm-none-eabi-objdump' + ' -dS' CSRC = [] @@ -43,7 +44,15 @@ BUILD_DIR = 'build' TARGET = 'hello' CFLAG = [ - "-Wall -pedantic -specs=nano.specs -mcpu=cortex-m4 -mthumb -lc -lm -lnosys -Og -Tstm32_app.ld", + "-Wall -pedantic -mcpu=cortex-m4 -mthumb -lc -lm -lnosys -Og", + "-pie", + # "-fPIC", + # "-fPIE", + "-msingle-pic-base", + "-specs=nano.specs", + # "-nostdlib -emain", + "", + "-Tstm32_app.ld", f"-Wl,-Map={BUILD_DIR}/{TARGET}.map,--cref -Wl,--gc-sections" ] @@ -174,6 +183,9 @@ def build_target(src:list[str]): def main(): global CSRC global ASRC + if(os.path.exists(f"{TARGET}.s")): + os.remove(f"{TARGET}.s") + CSRC+=find_type('./',['c','C']) ASRC+=find_type('./',['s','S','asm','ASM']) @@ -189,6 +201,7 @@ def main(): build_target(CSRC+ASRC) os.system(f"{HEX} {BUILD_DIR}/{TARGET} {BUILD_DIR}/{TARGET}.hex") os.system(f"{BIN} {BUILD_DIR}/{TARGET} {BUILD_DIR}/{TARGET}.bin") + os.system(f"{OD} {BUILD_DIR}/{TARGET} > {TARGET}.s") if __name__ == "__main__": main()