[CRIU] [PATCH 2/4] compel handle-elf.c: better align generated output

Kir Kolyshkin kir at openvz.org
Tue Dec 6 15:54:27 PST 2016


This is purely cosmetical, no functional change.

1. Make sure relocs table is well aligned.

2. printf("%#02x", 1) prints 0x01, but for 0 it prints 0,
   not 0x00 as one would expect, so output is somewhat ugly.
   Use "0x%02x" format instead to make it more uniform and
   well aligned.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 compel/src/lib/handle-elf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c
index b068ada..477358a 100644
--- a/compel/src/lib/handle-elf.c
+++ b/compel/src/lib/handle-elf.c
@@ -488,7 +488,7 @@ int __handle_elf(void *mem, size_t size)
 			case R_X86_64_32: /* Symbol + Addend (4 bytes) */
 			case R_X86_64_32S: /* Symbol + Addend (4 bytes) */
 				pr_debug("\t\t\t\tR_X86_64_32       at 0x%-4lx val 0x%x\n", place, value32);
-				pr_out("	{ .offset = 0x%-8x, .type = COMPEL_TYPE_INT, "
+				pr_out("	{ .offset = 0x%-8x, .type = COMPEL_TYPE_INT,  "
 				       ".addend = %-8d, .value = 0x%-16x, }, /* R_X86_64_32 */\n",
 				       (unsigned int)place, addend32, value32);
 				break;
@@ -524,7 +524,7 @@ int __handle_elf(void *mem, size_t size)
 #ifdef ELF_X86_32
 			case R_386_32: /* Symbol + Addend */
 				pr_debug("\t\t\t\tR_386_32   at 0x%-4lx val 0x%x\n", place, value32 + addend32);
-				pr_out("	{ .offset = 0x%-8x, .type = COMPEL_TYPE_INT, "
+				pr_out("	{ .offset = 0x%-8x, .type = COMPEL_TYPE_INT,  "
 				       ".addend = %-4d, .value = 0x%x, },\n",
 				       (unsigned int)place, addend32, value32);
 				break;
@@ -573,7 +573,7 @@ int __handle_elf(void *mem, size_t size)
 		for (j = 0; j < sh->sh_size; j++, k++) {
 			if (k && (k % 8) == 0)
 				pr_out("\n\t");
-			pr_out("%#02x,", shdata[j]);
+			pr_out("0x%02x,", shdata[j]);
 		}
 	}
 	pr_out("};\n");
-- 
2.7.4



More information about the CRIU mailing list