@@ -104,21 +104,41 @@ ifndef MAKE_TMPDIR
104104endif
105105
106106GENERATE_SECTION_MAP := $(AWK ) 'BEGIN { printf("") >ENVIRON["SECTION_MAP"]; } \
107+ /^Section Headers:/ { \
108+ in_sections = 1; \
109+ in_symbols = 0; \
110+ next; \
111+ } \
112+ /^Symbol table / { \
113+ if (! in_sections) { \
114+ print "symbol table appeared before section headers." >"/dev/stderr"; \
115+ exit(1); \
116+ } \
117+ in_sections = 0; \
118+ in_symbols = 1; \
119+ next; \
120+ } \
107121 { \
108- if ($$7 !~ "^[0-9]+$$") \
109- next; \
110- if ($$4 == "SECTION") { \
111- sections[$$7] = $$8; \
112- next; \
122+ if (in_sections) { \
123+ if (match($$0, \
124+ "^[[:space:]]*\\[[[:space:]]*([0-9]+)[[:space:]]*\\][[:space:]]+([^[:space:]]+)[[:space:]]",\
125+ section_line_a)) { \
126+ sections[section_line_a[1]] = section_line_a[2]; \
127+ next; \
128+ } \
113129 } \
114- if (($$4 == "NOTYPE") || ($$4 == "OBJECT") || ($$4 == "FUNC")) { \
115- if (($$8 == "$$d") || ($$8 == "$$t")) \
130+ if (in_symbols) { \
131+ if ($$7 !~ "^[0-9]+$$") \
116132 next; \
117- if ($$7 in sections) { \
118- if (sections[$$7] ~ "_wolfcrypt$$") \
119- print $$8 "\t" sections[$$7] >>ENVIRON["SECTION_MAP"]; \
120- } else \
121- print $$8 " is in section " $$7 " with no name mapping." >"/dev/stderr";\
133+ if (($$4 == "NOTYPE") || ($$4 == "OBJECT") || ($$4 == "FUNC")) { \
134+ if (($$8 == "$$d") || ($$8 == "$$t")) \
135+ next; \
136+ if ($$7 in sections) { \
137+ if (sections[$$7] ~ "_wolfcrypt$$") \
138+ print $$8 "\t" sections[$$7] >>ENVIRON["SECTION_MAP"]; \
139+ } else \
140+ print $$8 " is in section " $$7 " with no name mapping." >"/dev/stderr";\
141+ } \
122142 } \
123143 }'
124144
@@ -272,7 +292,7 @@ ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
272292 @SECTION_MAP=$$(mktemp)
273293 @trap 'rm "$$SECTION_MAP"' EXIT
274294 @export SECTION_MAP
275- @$(READELF) --wide --symbols "$@" | $(GENERATE_SECTION_MAP)
295+ @$(READELF) --wide --sections -- symbols "$@" | $(GENERATE_SECTION_MAP)
276296 @$(READELF) --wide --relocs "$@" | $(GENERATE_RELOC_TAB) >| '$(MODULE_TOP)/linuxkm/wc_linuxkm_pie_reloc_tab.c'
277297 +$(MAKE) ARCH='$(KERNEL_ARCH)' $(OVERRIDE_PATHS) $(CROSS_COMPILE) -C '$(KERNEL_ROOT)' M='$(MODULE_TOP)' $(KBUILD_EXTRA_FLAGS) CC_FLAGS_FTRACE=
278298 @$(READELF) --wide --relocs "$@" | $(GENERATE_RELOC_TAB) >| "$$RELOC_TMP"
0 commit comments