All of lore.kernel.org
 help / color / mirror / Atom feed
* [livepatch-build-tools part2 1/6] common: Add is_standard_section() helper function
@ 2019-04-16 12:07 Pawel Wieczorkiewicz
  2019-04-16 12:07 ` [livepatch-build-tools part2 2/6] common: Add is_referenced_section() " Pawel Wieczorkiewicz
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Pawel Wieczorkiewicz @ 2019-04-16 12:07 UTC (permalink / raw)
  To: xen-devel; +Cc: mpohlack, ross.lagerwall, Pawel Wieczorkiewicz, konrad.wilk

Detect standard (always to be included) sections via their section
header type. The standard sections: ".shstrtab", ".symtab", ".strtab"
are either of type SHT_SYMTAB or SHT_STRTAB.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
---
 common.c             | 12 ++++++++++++
 common.h             |  1 +
 create-diff-object.c |  5 +----
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/common.c b/common.c
index bc63955..1fb07cb 100644
--- a/common.c
+++ b/common.c
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <stdbool.h>
 #include <gelf.h>
 
 #include "list.h"
@@ -258,6 +259,17 @@ int is_debug_section(struct section *sec)
 	return !strncmp(name, ".debug_", 7);
 }
 
+int is_standard_section(struct section *sec)
+{
+	switch (sec->sh.sh_type) {
+	case SHT_STRTAB:
+	case SHT_SYMTAB:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /* returns the offset of the string in the string table */
 int offset_of_string(struct list_head *list, char *name)
 {
diff --git a/common.h b/common.h
index 7599fe7..cda690d 100644
--- a/common.h
+++ b/common.h
@@ -150,6 +150,7 @@ struct symbol *find_symbol_by_name(struct list_head *list, const char *name);
 int is_text_section(struct section *sec);
 int is_debug_section(struct section *sec);
 int is_rela_section(struct section *sec);
+int is_standard_section(struct section *sec);
 int is_local_sym(struct symbol *sym);
 
 void rela_insn(struct section *sec, struct rela *rela, struct insn *insn);
diff --git a/create-diff-object.c b/create-diff-object.c
index 82f777e..1e6e617 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1278,10 +1278,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
 
 	list_for_each_entry(sec, &kelf->sections, list) {
 		/* include these sections even if they haven't changed */
-		if (!strcmp(sec->name, ".shstrtab") ||
-		    !strcmp(sec->name, ".strtab") ||
-		    !strcmp(sec->name, ".symtab") ||
-		    should_include_str_section(sec->name)) {
+		if (is_standard_section(sec) || should_include_str_section(sec->name)) {
 			sec->include = 1;
 			if (sec->secsym)
 				sec->secsym->include = 1;
-- 
2.16.5




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2019-04-30 13:28 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 12:07 [livepatch-build-tools part2 1/6] common: Add is_standard_section() helper function Pawel Wieczorkiewicz
2019-04-16 12:07 ` [livepatch-build-tools part2 2/6] common: Add is_referenced_section() " Pawel Wieczorkiewicz
2019-04-29 15:14   ` Ross Lagerwall
2019-04-29 15:58     ` Wieczorkiewicz, Pawel
2019-04-16 12:07 ` [livepatch-build-tools part2 3/6] create-diff-object: Add is_special_section() " Pawel Wieczorkiewicz
2019-04-29 15:25   ` Ross Lagerwall
2019-04-30 12:18     ` Wieczorkiewicz, Pawel
2019-04-16 12:07 ` [livepatch-build-tools part2 4/6] livepatch-build: detect special section group sizes Pawel Wieczorkiewicz
2019-04-25  4:53   ` Konrad Rzeszutek Wilk
2019-04-29 14:14     ` Ross Lagerwall
2019-04-29 21:53       ` Glenn Enright
2019-04-29 14:10   ` Ross Lagerwall
2019-04-29 14:21     ` Ross Lagerwall
2019-04-29 15:19       ` Wieczorkiewicz, Pawel
2019-04-16 12:07 ` [livepatch-build-tools part2 5/6] create-diff-object: Add new entries to special sections array Pawel Wieczorkiewicz
2019-04-29 15:47   ` Ross Lagerwall
2019-04-30 13:01     ` Wieczorkiewicz, Pawel
2019-04-16 12:07 ` [livepatch-build-tools part2 6/6] create-diff-object: Do not include all .rodata sections Pawel Wieczorkiewicz
2019-04-29 16:11   ` Ross Lagerwall
2019-04-30 13:28     ` Wieczorkiewicz, Pawel
2019-04-29 15:07 ` [livepatch-build-tools part2 1/6] common: Add is_standard_section() helper function Ross Lagerwall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.