|
使用 gcc11.3 编译 g4eext,会在文件头部增加 16 字节:
00000000 04 00 00 00 10 00 00 00 05 00 00 00 47 4E 55 00 GNU
00000016 02 00 00 C0 04 00 00 00 03 00 00 00 00 00 00 00 ?
这影响外置命令执行。
1. 编译时增加什么参数,避免这 16 字节。
2. 生成外部命令后使用脚本删除这 16 字节。
Makefile 文件内容如下:
ifeq ($(CC),cc)
CC := gcc
endif
OBJCOPY := objcopy
RM := rm
MV := mv
MKDIR := mkdir
DATE = $(shell date -u +%Y-%m-%d)
GCCVERSIONGTEQ5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 5)
CFLAGS := -Wl,--build-id=none -m64 -mno-sse -nostdlib \
-fno-zero-initialized-in-bss -fno-function-cse \
-fshort-wchar -fno-jump-tables -Wl,-N
ifeq "$(GCCVERSIONGTEQ5)" "1"
CFLAGS += -no-pie
else
CFLAGS += -fPIE
endif
OBJECTS := $(patsubst %.c,%.o,$(wildcard *.c)) fat/fat.o
MODULES := $(patsubst %.c,%.mod,$(wildcard *.c)) fat/fat.mod
.PHONY: all
all: prepare $(MODULES)
zip -9 -j ../g4eext-$(DATE).zip bin/*
%.o: %.c
$(CC) $(CFLAGS) -Iinclude/ $< -o $@
%.mod: %.o
$(OBJCOPY) -O binary $< $@
# $(MV) $@ bin/$$(basename -s .mod $@)
$(MV) $@ bin/$$(basename $@ .mod)
.PHONY: prepare
prepare:
$(MKDIR) -p bin
.PHONY: clean
clean:
$(RM) -f *.o *.mod bin/* |
|