All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pawel Wieczorkiewicz <wipawel@amazon.de>
To: xen-devel@lists.xen.org
Cc: mpohlack@amazon.de, ross.lagerwall@citrix.com,
	Pawel Wieczorkiewicz <wipawel@amazon.de>,
	konrad.wilk@oracle.com
Subject: [livepatch-build-tools part2 6/6] create-diff-object: Do not include all .rodata sections
Date: Tue, 16 Apr 2019 12:07:16 +0000	[thread overview]
Message-ID: <20190416120716.26269-6-wipawel@amazon.de> (raw)
In-Reply-To: <20190416120716.26269-1-wipawel@amazon.de>

Starting with the "2af6f1aa6233 Fix patch creation with GCC 6.1+" commit
all .rodata sections are included by default (regardless of whether they
are needed or not).
During stacked hotpatch builds it leads to unnecessary duplication of
the .rodata sections as each and every consecutive hotpatch contains all
the .rodata section of previous hotpatches.

To prevent this situation, mark the .rodata section for inclusion only
if they are referenced by any of the current hotpatch symbols (or a
corresponding RELA section).

Extend patchability verification to detect all non-standard, non-rela,
non-debug and non-special sections that are not referenced by any of
the symbols or RELA sections.

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>
---
 create-diff-object.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/create-diff-object.c b/create-diff-object.c
index f6060cd..f7eb421 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1341,7 +1341,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 (is_standard_section(sec) || should_include_str_section(sec->name)) {
+		if (is_standard_section(sec)) {
 			sec->include = 1;
 			if (sec->secsym)
 				sec->secsym->include = 1;
@@ -1352,6 +1352,19 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
 	list_entry(kelf->symbols.next, struct symbol, list)->include = 1;
 }
 
+static void kpatch_include_standard_string_elements(struct kpatch_elf *kelf)
+{
+	struct section *sec;
+
+	list_for_each_entry(sec, &kelf->sections, list) {
+		if (should_include_str_section(sec->name) && is_referenced_section(sec, kelf)) {
+			sec->include = 1;
+			if (sec->secsym)
+				sec->secsym->include = 1;
+		}
+	}
+}
+
 #define inc_printf(fmt, ...) \
 	log_debug("%*s" fmt, recurselevel, "", ##__VA_ARGS__);
 
@@ -1531,6 +1544,16 @@ static void kpatch_verify_patchability(struct kpatch_elf *kelf)
 			errs++;
 		}
 
+		if (sec->include) {
+			if (!is_standard_section(sec) && !is_rela_section(sec) &&
+			    !is_debug_section(sec) && !is_special_section(sec)) {
+				if (!is_referenced_section(sec, kelf)) {
+					log_normal("section %s included, but not referenced\n", sec->name);
+					errs++;
+				}
+			}
+		}
+
 		/*
 		 * ensure we aren't including .data.* or .bss.*
 		 * (.data.unlikely is ok b/c it only has __warned vars)
@@ -2062,6 +2085,8 @@ int main(int argc, char *argv[])
 	kpatch_include_debug_sections(kelf_patched);
 	log_debug("Include hook elements\n");
 	kpatch_include_hook_elements(kelf_patched);
+	log_debug("Include standard string elements\n");
+	kpatch_include_standard_string_elements(kelf_patched);
 	log_debug("Include new globals\n");
 	new_globals_exist = kpatch_include_new_globals(kelf_patched);
 	log_debug("new_globals_exist = %d\n", new_globals_exist);
-- 
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

  parent reply	other threads:[~2019-04-16 12:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Pawel Wieczorkiewicz [this message]
2019-04-29 16:11   ` [livepatch-build-tools part2 6/6] create-diff-object: Do not include all .rodata sections 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416120716.26269-6-wipawel@amazon.de \
    --to=wipawel@amazon.de \
    --cc=konrad.wilk@oracle.com \
    --cc=mpohlack@amazon.de \
    --cc=ross.lagerwall@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.