From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: thuth@redhat.com, lvivier@redhat.com, rkrcmar@redhat.com
Subject: [kvm-unit-tests PATCH 3/4] arm/arm64: populate argv[0] with prognam
Date: Thu, 21 Apr 2016 15:32:39 +0200 [thread overview]
Message-ID: <1461245560-27813-4-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1461245560-27813-1-git-send-email-drjones@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/Makefile.common | 6 +++++-
lib/argv.c | 5 +++++
lib/auxinfo.h | 7 +++++++
scripts/auxinfo.mak | 7 +++++++
4 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 lib/auxinfo.h
create mode 100755 scripts/auxinfo.mak
diff --git a/arm/Makefile.common b/arm/Makefile.common
index 9a2d61fc88a27..6b87a48b0066b 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -26,6 +26,7 @@ CFLAGS += -I lib -I lib/libfdt
asm-offsets = lib/$(ARCH)/asm-offsets.h
include scripts/asm-offsets.mak
+include scripts/auxinfo.mak
cflatobjs += lib/util.o
cflatobjs += lib/alloc.o
@@ -49,9 +50,12 @@ start_addr := $(shell printf "%x\n" $$(( $(phys_base) + $(kernel_offset) )))
FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) $(libeabi)
%.elf: LDFLAGS = $(CFLAGS) -nostdlib
%.elf: %.o $(FLATLIBS) arm/flat.lds
+ $(call gen-auxinfo,$(@:.elf=.aux.c),$(@:.elf=.flat))
+ $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(@:.elf=.aux.c)
$(CC) $(LDFLAGS) -o $@ \
-Wl,-T,arm/flat.lds,--build-id=none,-Ttext=$(start_addr) \
- $(filter %.o, $^) $(FLATLIBS)
+ $(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
+ $(RM) $(@:.elf=.aux).*
%.flat: %.elf
$(OBJCOPY) -O binary $^ $@
diff --git a/lib/argv.c b/lib/argv.c
index c6ad5fcbc8cf4..47ecb14c9f2d7 100644
--- a/lib/argv.c
+++ b/lib/argv.c
@@ -1,4 +1,5 @@
#include "libcflat.h"
+#include "auxinfo.h"
int __argc;
char *__argv[100];
@@ -41,6 +42,10 @@ void setup_args(char *args)
for (int i = __argc; i > 0; --i)
__argv[i] = __argv[i-1];
}
+#if defined(__arm__) || defined(__aarch64__)
+ __argv[0] = (char *)auxinfo.prognam;
+#else
__argv[0] = NULL; //HACK: just reserve argv[0] for now
+#endif
++__argc;
}
diff --git a/lib/auxinfo.h b/lib/auxinfo.h
new file mode 100644
index 0000000000000..fc2d736aa63b1
--- /dev/null
+++ b/lib/auxinfo.h
@@ -0,0 +1,7 @@
+#ifndef _AUXINFO_H_
+#define _AUXINFO_H_
+struct auxinfo {
+ const char *prognam;
+};
+extern struct auxinfo auxinfo;
+#endif
diff --git a/scripts/auxinfo.mak b/scripts/auxinfo.mak
new file mode 100755
index 0000000000000..dbb588e89fc6f
--- /dev/null
+++ b/scripts/auxinfo.mak
@@ -0,0 +1,7 @@
+
+define gen-auxinfo
+ (echo "#include <auxinfo.h>"; \
+ echo "struct auxinfo auxinfo = {"; \
+ echo " .prognam = \"$(2)\","; \
+ echo "};" ) > $(1)
+endef
--
2.4.11
next prev parent reply other threads:[~2016-04-21 13:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 13:32 [kvm-unit-tests PATCH 0/4] arm/powerpc: make argv[0] the program name Andrew Jones
2016-04-21 13:32 ` [kvm-unit-tests PATCH 1/4] arm/arm64: reserve argv[0] for prognam Andrew Jones
2016-04-21 18:18 ` Thomas Huth
2016-04-22 8:03 ` Andrew Jones
2016-04-21 13:32 ` [kvm-unit-tests PATCH 2/4] powerpc/ppc64: " Andrew Jones
2016-04-21 13:32 ` Andrew Jones [this message]
2016-04-21 15:58 ` [kvm-unit-tests PATCH 3/4] arm/arm64: populate argv[0] with prognam Andrew Jones
2016-04-21 13:32 ` [kvm-unit-tests PATCH 4/4] powerpc/ppc64: " Andrew Jones
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=1461245560-27813-4-git-send-email-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=thuth@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox