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()