Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d809d369 authored by Ryan Prichard's avatar Ryan Prichard
Browse files

Fix mini_debug_info stripping when no symbols should be kept.

If there are no symbols to keep (i.e. all function symbols are also in
the dynsym table), then the $@.keep_symbols file has size 0.
When objcopy parses a --keep-symbols file, it has a special case for
0-sized files where it silently fails (exits with status 1, no error
message). On the other hand, objcopy is happy with a file containing no
symbols, as long as there is some whitespace or a comment. Avoid the
special case by appending a newline to keep_symbols.

Bug: b/62815515
Bug: b/77242617
Test: manual
Change-Id: I348593164fe78ece5c85db3d28c7daccce3a52fb
(cherry picked from commit a45f5833)
parent 86702c24
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1849,6 +1849,7 @@ if $(PRIVATE_STRIP) --strip-all -R .comment $< -o $@; then \
  $(PRIVATE_NM) -D $< --format=posix --defined-only | awk '{ print $$1 }' | sort >$@.dynsyms && \
  $(PRIVATE_NM) $< --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort >$@.funcsyms && \
  comm -13 $@.dynsyms $@.funcsyms >$@.keep_symbols && \
  echo >>$@.keep_symbols && \
  $(PRIVATE_OBJCOPY) --rename-section .debug_frame=saved_debug_frame $@.debug $@.mini_debuginfo && \
  $(PRIVATE_OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$@.keep_symbols $@.mini_debuginfo && \
  $(PRIVATE_OBJCOPY) --rename-section saved_debug_frame=.debug_frame $@.mini_debuginfo && \