make.py 添加反汇编输出

This commit is contained in:
ranchuan
2024-04-19 18:56:55 +08:00
parent b9f55eae30
commit 238b3dc734

15
make.py
View File

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