Makefile, m1n1.ld: Build with debug info

This allows addr2line to work. The Mach-O output should be unchanged.

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-09-21 15:36:56 +09:00
parent a16731e8b3
commit e08457aaa9
2 changed files with 47 additions and 4 deletions

View file

@ -12,7 +12,7 @@ LD := $(ARCH)ld
OBJCOPY := $(ARCH)objcopy
endif
CFLAGS := -O2 -Wall -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
-Werror=implicit-function-declaration -Werror=implicit-int \
-Wsign-compare -Wunused-parameter -Wno-multichar \
-ffreestanding -fpic -ffunction-sections -fdata-sections \
@ -21,7 +21,7 @@ CFLAGS := -O2 -Wall -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
-Wstack-usage=1024
LDFLAGS := -T m1n1.ld -EL -maarch64elf --no-undefined -X -Bsymbolic \
-z notext --no-apply-dynamic-relocs --orphan-handling=warn --strip-debug \
-z notext --no-apply-dynamic-relocs --orphan-handling=warn \
-z nocopyreloc --gc-sections -pie
MINILZLIB_OBJECTS := $(patsubst %,minilzlib/%, \
@ -118,7 +118,7 @@ build/$(NAME).elf: $(BUILD_OBJS) m1n1.ld
build/$(NAME).macho: build/$(NAME).elf
@echo " MACHO $@"
@$(OBJCOPY) -O binary $< $@
@$(OBJCOPY) -O binary --strip-debug $< $@
update_tag:
@echo "#define BUILD_TAG \"$$(git describe --always --dirty)\"" > build/build_tag.tmp

45
m1n1.ld
View file

@ -142,7 +142,14 @@ SECTIONS {
.rela.dyn : {
_rela_start = .;
*(.rela)
*(.rela.*)
*(.rela.text)
*(.rela.got)
*(.rela.plt)
*(.rela.bss)
*(.rela.ifunc)
*(.rela.text.*)
*(.rela.data)
*(.rela.data.*)
_rela_end = .;
. = ALIGN(0x4000);
} :rodata
@ -201,6 +208,42 @@ SECTIONS {
*(.got.plt)
}
ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT PLT detected!")
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
.debug_types 0 : { *(.debug_types) }
.debug_addr 0 : { *(.debug_addr) }
.debug_line_str 0 : { *(.debug_line_str) }
.debug_loclists 0 : { *(.debug_loclists) }
.debug_macro 0 : { *(.debug_macro) }
.debug_names 0 : { *(.debug_names) }
.debug_rnglists 0 : { *(.debug_rnglists) }
.debug_str_offsets 0 : { *(.debug_str_offsets) }
.debug_sup 0 : { *(.debug_sup) }
}
PROT_READ = 0x01;