From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, luto@amacapital.net, hpa@zytor.com,
mingo@kernel.org, tglx@linutronix.de, hpa@linux.intel.com
Subject: [tip:x86/urgent] x86/vdso2c: Use better macros for ELF bitness
Date: Fri, 20 Jun 2014 19:07:36 -0700 [thread overview]
Message-ID: <tip-c1979c370273fd9f7326ffa27a63b9ddb0f495f4@git.kernel.org> (raw)
In-Reply-To: <d953cd2e70ceee1400985d091188cdd65fba2f05.1403129369.git.luto@amacapital.net>
Commit-ID: c1979c370273fd9f7326ffa27a63b9ddb0f495f4
Gitweb: http://git.kernel.org/tip/c1979c370273fd9f7326ffa27a63b9ddb0f495f4
Author: Andy Lutomirski <luto@amacapital.net>
AuthorDate: Wed, 18 Jun 2014 15:59:47 -0700
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 19 Jun 2014 15:44:59 -0700
x86/vdso2c: Use better macros for ELF bitness
Rather than using a separate macro for each replacement, use generic
macros.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/d953cd2e70ceee1400985d091188cdd65fba2f05.1403129369.git.luto@amacapital.net
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/vdso/vdso2c.c | 42 +++++++++++++-----------------------------
arch/x86/vdso/vdso2c.h | 23 ++++++++++++-----------
2 files changed, 25 insertions(+), 40 deletions(-)
diff --git a/arch/x86/vdso/vdso2c.c b/arch/x86/vdso/vdso2c.c
index 7a6bf50..7343899 100644
--- a/arch/x86/vdso/vdso2c.c
+++ b/arch/x86/vdso/vdso2c.c
@@ -83,37 +83,21 @@ extern void bad_put_le(void);
#define NSYMS (sizeof(required_syms) / sizeof(required_syms[0]))
-#define BITS 64
-#define GOFUNC go64
-#define Elf_Ehdr Elf64_Ehdr
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Phdr Elf64_Phdr
-#define Elf_Sym Elf64_Sym
-#define Elf_Dyn Elf64_Dyn
+#define BITSFUNC3(name, bits) name##bits
+#define BITSFUNC2(name, bits) BITSFUNC3(name, bits)
+#define BITSFUNC(name) BITSFUNC2(name, ELF_BITS)
+
+#define ELF_BITS_XFORM2(bits, x) Elf##bits##_##x
+#define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x)
+#define ELF(x) ELF_BITS_XFORM(ELF_BITS, x)
+
+#define ELF_BITS 64
#include "vdso2c.h"
-#undef BITS
-#undef GOFUNC
-#undef Elf_Ehdr
-#undef Elf_Shdr
-#undef Elf_Phdr
-#undef Elf_Sym
-#undef Elf_Dyn
-
-#define BITS 32
-#define GOFUNC go32
-#define Elf_Ehdr Elf32_Ehdr
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Phdr Elf32_Phdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Dyn Elf32_Dyn
+#undef ELF_BITS
+
+#define ELF_BITS 32
#include "vdso2c.h"
-#undef BITS
-#undef GOFUNC
-#undef Elf_Ehdr
-#undef Elf_Shdr
-#undef Elf_Phdr
-#undef Elf_Sym
-#undef Elf_Dyn
+#undef ELF_BITS
static void go(void *addr, size_t len, FILE *outfile, const char *name)
{
diff --git a/arch/x86/vdso/vdso2c.h b/arch/x86/vdso/vdso2c.h
index c6eefaf..8e185ce 100644
--- a/arch/x86/vdso/vdso2c.h
+++ b/arch/x86/vdso/vdso2c.h
@@ -4,23 +4,24 @@
* are built for 32-bit userspace.
*/
-static void GOFUNC(void *addr, size_t len, FILE *outfile, const char *name)
+static void BITSFUNC(go)(void *addr, size_t len,
+ FILE *outfile, const char *name)
{
int found_load = 0;
unsigned long load_size = -1; /* Work around bogus warning */
unsigned long data_size;
- Elf_Ehdr *hdr = (Elf_Ehdr *)addr;
+ ELF(Ehdr) *hdr = (ELF(Ehdr) *)addr;
int i;
unsigned long j;
- Elf_Shdr *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
+ ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
*alt_sec = NULL;
- Elf_Dyn *dyn = 0, *dyn_end = 0;
+ ELF(Dyn) *dyn = 0, *dyn_end = 0;
const char *secstrings;
uint64_t syms[NSYMS] = {};
uint64_t fake_sections_value = 0, fake_sections_size = 0;
- Elf_Phdr *pt = (Elf_Phdr *)(addr + GET_LE(&hdr->e_phoff));
+ ELF(Phdr) *pt = (ELF(Phdr) *)(addr + GET_LE(&hdr->e_phoff));
/* Walk the segment table. */
for (i = 0; i < GET_LE(&hdr->e_phnum); i++) {
@@ -61,7 +62,7 @@ static void GOFUNC(void *addr, size_t len, FILE *outfile, const char *name)
GET_LE(&hdr->e_shentsize)*GET_LE(&hdr->e_shstrndx);
secstrings = addr + GET_LE(&secstrings_hdr->sh_offset);
for (i = 0; i < GET_LE(&hdr->e_shnum); i++) {
- Elf_Shdr *sh = addr + GET_LE(&hdr->e_shoff) +
+ ELF(Shdr) *sh = addr + GET_LE(&hdr->e_shoff) +
GET_LE(&hdr->e_shentsize) * i;
if (GET_LE(&sh->sh_type) == SHT_SYMTAB)
symtab_hdr = sh;
@@ -82,7 +83,7 @@ static void GOFUNC(void *addr, size_t len, FILE *outfile, const char *name)
i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
i++) {
int k;
- Elf_Sym *sym = addr + GET_LE(&symtab_hdr->sh_offset) +
+ ELF(Sym) *sym = addr + GET_LE(&symtab_hdr->sh_offset) +
GET_LE(&symtab_hdr->sh_entsize) * i;
const char *name = addr + GET_LE(&strtab_hdr->sh_offset) +
GET_LE(&sym->st_name);
@@ -123,12 +124,12 @@ static void GOFUNC(void *addr, size_t len, FILE *outfile, const char *name)
fail("end_mapping must be a multiple of 4096\n");
/* Remove sections or use fakes */
- if (fake_sections_size % sizeof(Elf_Shdr))
+ if (fake_sections_size % sizeof(ELF(Shdr)))
fail("vdso_fake_sections size is not a multiple of %ld\n",
- (long)sizeof(Elf_Shdr));
+ (long)sizeof(ELF(Shdr)));
PUT_LE(&hdr->e_shoff, fake_sections_value);
- PUT_LE(&hdr->e_shentsize, fake_sections_value ? sizeof(Elf_Shdr) : 0);
- PUT_LE(&hdr->e_shnum, fake_sections_size / sizeof(Elf_Shdr));
+ PUT_LE(&hdr->e_shentsize, fake_sections_value ? sizeof(ELF(Shdr)) : 0);
+ PUT_LE(&hdr->e_shnum, fake_sections_size / sizeof(ELF(Shdr)));
PUT_LE(&hdr->e_shstrndx, SHN_UNDEF);
if (!name) {
next prev parent reply other threads:[~2014-06-21 2:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 22:59 [PATCH 0/5] x86,vdso: Restore a bunch of section headers Andy Lutomirski
2014-06-18 22:59 ` [PATCH 1/5] x86,vdso: Discard the __bug_table section Andy Lutomirski
2014-06-21 2:07 ` [tip:x86/urgent] x86/vdso: " tip-bot for Andy Lutomirski
2014-06-22 8:47 ` Ingo Molnar
2014-06-22 16:59 ` Andy Lutomirski
2014-06-24 18:19 ` Andy Lutomirski
2014-06-24 18:26 ` H. Peter Anvin
2014-06-24 18:37 ` Andy Lutomirski
2014-06-24 18:43 ` H. Peter Anvin
2014-06-24 19:40 ` Andy Lutomirski
2014-06-24 19:50 ` [PATCH 0/2] x86: Build fixes for tip/x86/urgent Andy Lutomirski
2014-06-24 19:50 ` [PATCH 1/2] x86,vdso: Move DISABLE_BRANCH_PROFILING into the vdso makefile Andy Lutomirski
2014-06-24 20:09 ` H. Peter Anvin
2014-06-24 19:50 ` [PATCH 2/2] x86,vdso2c: Error out if DT_RELA is present Andy Lutomirski
2014-06-24 20:46 ` [PATCH v2 0/2] x86: Build fixes for tip/x86/urgent Andy Lutomirski
2014-06-24 20:46 ` [PATCH v2 1/2] x86,vdso: Move DISABLE_BRANCH_PROFILING into the vdso makefile Andy Lutomirski
2014-06-24 22:16 ` [tip:x86/urgent] x86/vdso: " tip-bot for Andy Lutomirski
2014-06-24 20:46 ` [PATCH v2 2/2] x86,vdso2c: Error out if DT_RELA is present Andy Lutomirski
2014-06-24 22:16 ` [tip:x86/urgent] x86/vdso: Error out in vdso2c " tip-bot for Andy Lutomirski
2014-06-24 18:29 ` [tip:x86/urgent] x86/vdso: Discard the __bug_table section H. Peter Anvin
2014-06-24 18:47 ` H. Peter Anvin
2014-06-18 22:59 ` [PATCH 2/5] x86,vdso2c: Use better macros for ELF bitness Andy Lutomirski
2014-06-21 2:07 ` tip-bot for Andy Lutomirski [this message]
2014-06-18 22:59 ` [PATCH 3/5] x86,vdso: Improve the fake section headers Andy Lutomirski
2014-06-21 2:07 ` [tip:x86/urgent] x86/vdso: " tip-bot for Andy Lutomirski
2014-06-18 22:59 ` [PATCH 4/5] x86,vdso: Remove some redundant in-memory " Andy Lutomirski
2014-06-21 2:08 ` [tip:x86/urgent] x86/vdso: " tip-bot for Andy Lutomirski
2014-06-18 22:59 ` [PATCH 5/5] x86,vdso: Create .build-id links for unstripped vdso files Andy Lutomirski
2014-06-19 22:46 ` H. Peter Anvin
2014-06-19 23:59 ` Andy Lutomirski
2014-06-19 22:42 ` [PATCH 0/5] x86,vdso: Restore a bunch of section headers H. Peter Anvin
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=tip-c1979c370273fd9f7326ffa27a63b9ddb0f495f4@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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