Skip to contentSkip to conversation

symbols: aliasing at text section boundaries

PATCH In review Jan Beulich 2 participants 6 messages Aug 25 – Sep 22

lore
Share & tools
lore
#0 lore raw

v2 cover symbols: aliasing at text section boundaries

1: drop _{s,e}extratext
2: also special-case symbols aliasing _sinittext

v2: New 1st patch, simplifying what's now patch2.

Jan

#1 lore raw

PATCH v2 1/2 symbols: drop _{s,e}extratext

We're only about 18.5 years late with this: See Linux commit a3b81113fb66 ("remove support for un-needed _extratext section"), i.e. from the 2.6.25 dev cycle.

---
v2: New.

xen/tools/symbols.c +6 -12
@@ -52,7 +52,7 @@ struct sym_entry {
 
 static struct sym_entry *table;
 static unsigned int table_size, table_cnt;
-static unsigned long long _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
+static unsigned long long _stext, _etext, _sinittext, _einittext;
 static int all_symbols = 0;
 static int sort_by_name = 0;
 static int map_only = 0;
@@ -148,10 +148,6 @@ static int read_symbol(FILE *in, struct
 		_sinittext = s->addr;
 	else if (strcmp(sym, "_einittext") == 0)
 		_einittext = s->addr;
-	else if (strcmp(sym, "_sextratext") == 0)
-		_sextratext = s->addr;
-	else if (strcmp(sym, "_eextratext") == 0)
-		_eextratext = s->addr;
 	else if (toupper((uint8_t)stype) == 'A')
 	{
 		/* Keep these useful absolute symbols */
@@ -210,18 +206,16 @@ static int symbol_valid(struct sym_entry
 	 * and inittext sections are discarded */
 	if (!all_symbols) {
 		if ((s->addr < _stext || s->addr > _etext)
-		    && (s->addr < _sinittext || s->addr > _einittext)
-		    && (s->addr < _sextratext || s->addr > _eextratext))
+		    && (s->addr < _sinittext || s->addr > _einittext))
 			return 0;
 		/* Corner case.  Discard any symbols with the same value as
-		 * _etext _einittext or _eextratext; they can move between pass
-		 * 1 and 2 when the symbols data are added.  If these symbols
-		 * move then they may get dropped in pass 2, which breaks the
+		 * _etext or _einittext; they can move between pass 1 and 2
+		 * when the symbols data are added.  If these symbols move
+		 * then they may get dropped in pass 2, which breaks the
 		 * symbols rules.
 		 */
 		if ((s->addr == _etext && strcmp((char*)s->sym + offset, "_etext")) ||
-		    (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")) ||
-		    (s->addr == _eextratext && strcmp((char*)s->sym + offset, "_eextratext")))
+		    (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")))
 			return 0;
 	}
 
#3 lore raw

PATCH v2 2/2 symbols: also special-case symbols aliasing _sinittext

In reply to Jan Beulich

A recent 4.22 randconfig build job hit a situation where (LIVEPATCH=n, i.e. --all-symbols not specified) both __note_gnu_build_id_end and _erodata aliased _sinittext on the 1st linking pass, but they didn't on the 2nd one. As a result two fewer symbols were emitted on the 2nd pass, causing $(call compare-symbol-tables, ...) to fail.

Extend the existing "corner case" by also considering aliases with _sinittext (_stext really shouldn't have anything ahead of it), but discard only non-text symbols.

---
v2: Re-base over _{s,e}extratext removal. Add const to cast.

xen/tools/symbols.c +5 -0
@@ -217,6 +217,11 @@ static int symbol_valid(struct sym_entry
 		if ((s->addr == _etext && strcmp((char*)s->sym + offset, "_etext")) ||
 		    (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")))
 			return 0;
+		/* Same for non-text aliases of _sinittext or _sextratext. */
+		if (toupper(*s->sym) != 'T'
+		    && s->addr == _sinittext
+		    && strcmp((const char *)s->sym + offset, "_sinittext"))
+			return 0;
 	}
 
 	/* Exclude symbols which vary between passes. */
#4 lore raw

Re: [PATCH v2 2/2] symbols: also special-case symbols aliasing _sinittext

Quoted 17 lines · Jan Beulich

A recent 4.22 randconfig build job hit a situation where (LIVEPATCH=n, i.e. --all-symbols not specified) both __note_gnu_build_id_end and _erodata aliased _sinittext on the 1st linking pass, but they didn't on the 2nd one. As a result two fewer symbols were emitted on the 2nd pass, causing $(call compare-symbol-tables, ...) to fail.

Extend the existing "corner case" by also considering aliases with _sinittext (_stext really shouldn't have anything ahead of it), but discard only non-text symbols.

---
v2: Re-base over _{s,e}extratext removal. Add const to cast.

xen/tools/symbols.c static int symbol_valid(struct sym_entry · line 220

Quoted 4 lines
xen/tools/symbols.c +1 -0
@@ -217,6 +217,11 @@ static int symbol_valid(struct sym_entry
 		if ((s->addr == _etext && strcmp((char*)s->sym + offset, "_etext")) ||
 		    (s->addr == _einittext && strcmp((char*)s->sym + offset, "_einittext")))
 			return 0;
+		/* Same for non-text aliases of _sinittext or _sextratext. */

I've locally dropped this leftover mention of _sextratext.

Jan

Quoted 8 lines
xen/tools/symbols.c +4 -0
+		if (toupper(*s->sym) != 'T'
+		    && s->addr == _sinittext
+		    && strcmp((const char *)s->sym + offset, "_sinittext"))
+			return 0;
 	}
 
 	/* Exclude symbols which vary between passes. */
Acked-by on v2 2/2
#5 lore raw

Re: [PATCH v2 2/2] symbols: also special-case symbols aliasing _sinittext

In reply to Jan Beulich
Quoted 11 lines · Jan Beulich

A recent 4.22 randconfig build job hit a situation where (LIVEPATCH=n, i.e. --all-symbols not specified) both __note_gnu_build_id_end and _erodata aliased _sinittext on the 1st linking pass, but they didn't on the 2nd one. As a result two fewer symbols were emitted on the 2nd pass, causing $(call compare-symbol-tables, ...) to fail.

Extend the existing "corner case" by also considering aliases with _sinittext (_stext really shouldn't have anything ahead of it), but discard only non-text symbols.

(with the _sextratext mention removed)

Thanks, Roger.