summaryrefslogtreecommitdiff
path: root/src/bldprogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bldprogs')
-rw-r--r--src/bldprogs/Makefile.kmk6
-rw-r--r--src/bldprogs/VBoxDef2LazyLoad.cpp635
-rw-r--r--src/bldprogs/VBoxTpG.cpp38
-rw-r--r--src/bldprogs/bin2c.c2
-rw-r--r--src/bldprogs/biossums.c2
-rwxr-xr-xsrc/bldprogs/checkUndefined.sh59
-rw-r--r--src/bldprogs/filesplitter.cpp46
-rw-r--r--src/bldprogs/preload.cpp4
-rw-r--r--src/bldprogs/scm.cpp15
-rw-r--r--src/bldprogs/scmstream.cpp2
-rw-r--r--src/bldprogs/scmsubversion.cpp2
11 files changed, 729 insertions, 82 deletions
diff --git a/src/bldprogs/Makefile.kmk b/src/bldprogs/Makefile.kmk
index 95cb2973..1e93f8a1 100644
--- a/src/bldprogs/Makefile.kmk
+++ b/src/bldprogs/Makefile.kmk
@@ -61,5 +61,11 @@ BLDPROGS.win += VBoxPeSetVersion
VBoxPeSetVersion_TEMPLATE = VBOXBLDPROG
VBoxPeSetVersion_SOURCES = VBoxPeSetVersion.cpp
+
+BLDPROGS += VBoxDef2LazyLoad
+VBoxDef2LazyLoad_TEMPLATE = VBOXBLDPROG
+VBoxDef2LazyLoad_SOURCES = VBoxDef2LazyLoad.cpp
+
+
include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/src/bldprogs/VBoxDef2LazyLoad.cpp b/src/bldprogs/VBoxDef2LazyLoad.cpp
new file mode 100644
index 00000000..fe0006a5
--- /dev/null
+++ b/src/bldprogs/VBoxDef2LazyLoad.cpp
@@ -0,0 +1,635 @@
+/* $Id: VBoxDef2LazyLoad.cpp $ */
+/** @file
+ * VBoxDef2LazyLoad - Lazy Library Loader Generator.
+ *
+ * @note Only tested on win.amd64.
+ */
+
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/*******************************************************************************
+* Header Files *
+*******************************************************************************/
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <iprt/types.h>
+
+
+/*******************************************************************************
+* Structures and Typedefs *
+*******************************************************************************/
+typedef struct MYEXPORT
+{
+ struct MYEXPORT *pNext;
+ bool fNoName;
+ unsigned uOrdinal;
+ char szName[1];
+} MYEXPORT;
+typedef MYEXPORT *PMYEXPORT;
+
+
+
+/*******************************************************************************
+* Global Variables *
+*******************************************************************************/
+/** @name Options
+ * @{ */
+static const char *g_pszOutput = NULL;
+static const char *g_pszInput = NULL;
+static const char *g_pszLibrary = NULL;
+static bool g_fIgnoreData = true;
+/** @} */
+
+/** Pointer to the export name list head. */
+static PMYEXPORT g_pExpHead = NULL;
+/** Pointer to the next pointer for insertion. */
+static PMYEXPORT *g_ppExpNext = &g_pExpHead;
+
+
+
+static const char *leftStrip(const char *psz)
+{
+ while (isspace(*psz))
+ psz++;
+ return psz;
+}
+
+
+static char *leftStrip(char *psz)
+{
+ while (isspace(*psz))
+ psz++;
+ return psz;
+}
+
+
+static unsigned wordLength(const char *pszWord)
+{
+ unsigned off = 0;
+ char ch;
+ while ( (ch = pszWord[off]) != '\0'
+ && ch != '='
+ && ch != ','
+ && ch != ':'
+ && !isspace(ch) )
+ off++;
+ return off;
+}
+
+
+/**
+ * Parses the module definition file, collecting export information.
+ *
+ * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE, in the latter case full
+ * details has been displayed.
+ * @param pInput The input stream.
+ */
+static RTEXITCODE parseInputInner(FILE *pInput)
+{
+ /*
+ * Process the file line-by-line.
+ */
+ bool fInExports = false;
+ unsigned iLine = 0;
+ char szLine[16384];
+ while (fgets(szLine, sizeof(szLine), pInput))
+ {
+ iLine++;
+
+ /*
+ * Strip leading and trailing spaces from the line as well as
+ * trailing comments.
+ */
+ char *psz = leftStrip(szLine);
+ if (*psz == ';')
+ continue; /* comment line. */
+
+ char *pszComment = strchr(psz, ';');
+ if (pszComment)
+ *pszComment = '\0';
+
+ unsigned cch = (unsigned)strlen(psz);
+ while (cch > 0 && (isspace(psz[cch - 1]) || psz[cch - 1] == '\r' || psz[cch - 1] == '\n'))
+ psz[--cch] = '\0';
+
+ if (!cch)
+ continue;
+
+ /*
+ * Check for known directives.
+ */
+ size_t cchWord0 = wordLength(psz);
+#define WORD_CMP(pszWord1, cchWord1, szWord2) \
+ ( (cchWord1) == sizeof(szWord2) - 1 && memcmp(pszWord1, szWord2, sizeof(szWord2) - 1) == 0 )
+ if (WORD_CMP(psz, cchWord0, "EXPORTS"))
+ {
+ fInExports = true;
+
+ /* In case there is an export on the same line. (Really allowed?) */
+ psz = leftStrip(psz + sizeof("EXPORTS") - 1);
+ if (!*psz)
+ continue;
+ }
+ /* Directives that we don't care about, but need to catch in order to
+ terminate the EXPORTS section in a timely manner. */
+ else if ( WORD_CMP(psz, cchWord0, "NAME")
+ || WORD_CMP(psz, cchWord0, "LIBRARY")
+ || WORD_CMP(psz, cchWord0, "DESCRIPTION")
+ || WORD_CMP(psz, cchWord0, "STACKSIZE")
+ || WORD_CMP(psz, cchWord0, "SECTIONS")
+ || WORD_CMP(psz, cchWord0, "SEGMENTS")
+ || WORD_CMP(psz, cchWord0, "VERSION")
+ )
+ {
+ fInExports = false;
+ }
+
+ /*
+ * Process exports:
+ * entryname[=internalname] [@ordinal[ ][NONAME]] [DATA] [PRIVATE]
+ */
+ if (fInExports)
+ {
+ const char *pchName = psz;
+ unsigned cchName = wordLength(psz);
+
+ psz = leftStrip(psz + cchName);
+ if (*psz == '=')
+ {
+ psz = leftStrip(psz + 1);
+ psz = leftStrip(psz + wordLength(psz));
+ }
+
+ bool fNoName = true;
+ unsigned uOrdinal = ~0U;
+ if (*psz == '@')
+ {
+ psz++;
+ if (!isdigit(*psz))
+ {
+ fprintf(stderr, "%s:%u: error: Invalid ordinal spec.\n", g_pszInput, iLine);
+ return RTEXITCODE_FAILURE;
+ }
+ uOrdinal = *psz++ - '0';
+ while (isdigit(*psz))
+ {
+ uOrdinal *= 10;
+ uOrdinal += *psz++ - '0';
+ }
+ psz = leftStrip(psz);
+ cch = wordLength(psz);
+ if (WORD_CMP(psz, cch, "NONAME"))
+ {
+#if 0
+ fNoName = true;
+ psz = leftStrip(psz + cch);
+#else
+ fprintf(stderr, "%s:%u: error: NONAME export not implemented.\n", g_pszInput, iLine);
+ return RTEXITCODE_FAILURE;
+#endif
+ }
+ }
+
+ while (*psz)
+ {
+ cch = wordLength(psz);
+ if (WORD_CMP(psz, cch, "DATA"))
+ {
+ if (!g_fIgnoreData)
+ {
+ fprintf(stderr, "%s:%u: error: Cannot wrap up DATA export '%.*s'.\n",
+ g_pszInput, iLine, cchName, pchName);
+ return RTEXITCODE_SUCCESS;
+ }
+ }
+ else if (!WORD_CMP(psz, cch, "PRIVATE"))
+ {
+ fprintf(stderr, "%s:%u: error: Cannot wrap up DATA export '%.*s'.\n",
+ g_pszInput, iLine, cchName, pchName);
+ return RTEXITCODE_SUCCESS;
+ }
+ psz = leftStrip(psz + cch);
+ }
+
+ /*
+ * Add the export.
+ */
+ PMYEXPORT pExp = (PMYEXPORT)malloc(sizeof(*pExp) + cchName);
+ if (!pExp)
+ {
+ fprintf(stderr, "%s:%u: error: Out of memory.\n", g_pszInput, iLine);
+ return RTEXITCODE_SUCCESS;
+ }
+ memcpy(pExp->szName, pchName, cchName);
+ pExp->szName[cchName] = '\0';
+ pExp->uOrdinal = uOrdinal;
+ pExp->fNoName = fNoName;
+ pExp->pNext = NULL;
+ *g_ppExpNext = pExp;
+ g_ppExpNext = &pExp->pNext;
+ }
+ }
+
+ /*
+ * Why did we quit the loop, EOF or error?
+ */
+ if (feof(pInput))
+ return RTEXITCODE_SUCCESS;
+ fprintf(stderr, "error: Read while reading '%s' (iLine=%u).\n", g_pszInput, iLine);
+ return RTEXITCODE_FAILURE;
+}
+
+
+/**
+ * Parses g_pszInput, populating the list pointed to by g_pExpHead.
+ *
+ * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE, in the latter case full
+ * details has been displayed.
+ */
+static RTEXITCODE parseInput(void)
+{
+ RTEXITCODE rcExit = RTEXITCODE_FAILURE;
+ FILE *pInput = fopen(g_pszInput, "r");
+ if (pInput)
+ {
+ rcExit = parseInputInner(pInput);
+ fclose(pInput);
+ if (rcExit == RTEXITCODE_SUCCESS && !g_pExpHead)
+ {
+ fprintf(stderr, "error: Found no exports in '%s'.\n", g_pszInput);
+ rcExit = RTEXITCODE_FAILURE;
+ }
+ }
+ else
+ fprintf(stderr, "error: Failed to open '%s' for reading.\n", g_pszInput);
+ return rcExit;
+}
+
+
+/**
+ * Generates the assembly source code, writing it to @a pOutput.
+ *
+ * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE, in the latter case full
+ * details has been displayed.
+ * @param pOutput The output stream (caller checks it for errors
+ * when closing).
+ */
+static RTEXITCODE generateOutputInner(FILE *pOutput)
+{
+ fprintf(pOutput,
+ ";; Autogenerated from '%s'. DO NOT EDIT!\n"
+ "\n"
+ "%%include \"iprt/asmdefs.mac\"\n"
+ "\n"
+ "BEGINCODE\n",
+ g_pszInput);
+
+ for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext)
+ {
+ fprintf(pOutput,
+ "BEGINDATA\n"
+ "%%ifdef ASM_FORMAT_PE\n"
+ "global __imp_%s\n"
+ "__imp_%s:\n"
+ "%%endif\n"
+ "g_pfn%s RTCCPTR_DEF ___LazyLoad___%s\n"
+ "BEGINCODE\n"
+ "BEGINPROC %s\n"
+ " jmp RTCCPTR_PRE [g_pfn%s xWrtRIP]\n"
+ "ENDPROC %s\n"
+ "___LazyLoad___%s:\n"
+ /* "int3\n" */
+ "%%ifdef RT_ARCH_AMD64\n"
+ " lea rax, [.szName wrt rip]\n"
+ " lea r10, [g_pfn%s wrt rip]\n"
+ "%%elifdef RT_ARCH_X86\n"
+ " push .szName\n"
+ " push g_pfn%s\n"
+ "%%else\n"
+ " %%error \"Unsupported architecture\"\n"
+ "%%endif\n"
+ " call NAME(LazyLoadResolver)\n"
+ "%%ifdef RT_ARCH_X86\n"
+ " add esp, 8h\n"
+ "%%endif\n"
+ " jmp NAME(%s)\n"
+ ".szName db '%s',0\n"
+ "\n"
+ ,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName, pExp->szName,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName,
+ pExp->szName);
+ }
+
+ /*
+ * The code that does the loading and resolving.
+ */
+ fprintf(pOutput,
+ "BEGINDATA\n"
+ "g_hMod RTCCPTR_DEF 0\n"
+ "\n"
+ "BEGINCODE\n");
+
+ /*
+ * How we load the module needs to be selectable later on.
+ *
+ * The LazyLoading routine returns the module handle in RCX/ECX, caller
+ * saved all necessary registers.
+ */
+ fprintf(pOutput,
+ ";\n"
+ ";SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, \n"
+ "; uint32_t fFlags, PRTERRINFO pErrInfo);\n"
+ ";\n"
+ "extern IMPNAME(SUPR3HardenedLdrLoadAppPriv)\n"
+ "\n"
+ "BEGINPROC LazyLoading\n"
+ " mov xCX, [g_hMod xWrtRIP]\n"
+ " or xCX, xCX\n"
+ " jnz .return\n"
+ "\n"
+ "%%ifdef ASM_CALL64_GCC\n"
+ " xor rcx, rcx ; pErrInfo (local load)\n"
+ " xor rdx, rdx ; fFlags (local load)\n"
+ " lea rsi, [g_hMod wrt rip] ; phLdrMod\n"
+ " lea rdi, [.szLib wrt rip] ; pszFilename\n"
+ " sub rsp, 08h\n"
+ " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n"
+ " add rsp, 08h\n"
+ "\n"
+ "%%elifdef ASM_CALL64_MSC\n"
+ " xor r9, r9 ; pErrInfo (local load)\n"
+ " xor r8, r8 ; fFlags (local load)\n"
+ " lea rdx, [g_hMod wrt rip] ; phLdrMod\n"
+ " lea rcx, [.szLib wrt rip] ; pszFilename\n"
+ " sub rsp, 28h\n"
+ " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n"
+ " add rsp, 28h\n"
+ "\n"
+ "%%elifdef RT_ARCH_X86\n"
+ " sub rsp, 0ch\n"
+ " push 0 ; pErrInfo\n"
+ " push 0 ; fFlags (local load)\n"
+ " push g_hMod ; phLdrMod\n"
+ " push .szLib ; pszFilename\n"
+ " call IMP2(SUPR3HardenedLdrLoadAppPriv)\n"
+ " add esp, 1ch\n"
+ "%%else\n"
+ " %%error \"Unsupported architecture\"\n"
+ "%%endif\n"
+ " or eax, eax\n"
+ " jz .loadok\n"
+ ".badload:\n"
+ " int3\n"
+ " jmp .badload\n"
+ ".loadok:\n"
+ " mov xCX, [g_hMod xWrtRIP]\n"
+ ".return:\n"
+ " ret\n"
+ ".szLib db '%s',0\n"
+ "ENDPROC LazyLoading\n"
+ , g_pszLibrary);
+
+
+ fprintf(pOutput,
+ "\n"
+ ";\n"
+ ";RTDECL(int) RTLdrGetSymbol(RTLDRMOD hLdrMod, const char *pszSymbol, void **ppvValue);\n"
+ ";\n"
+ "extern IMPNAME(RTLdrGetSymbol)\n"
+ "BEGINPROC LazyLoadResolver\n"
+ "%%ifdef RT_ARCH_AMD64\n"
+ " push rbp\n"
+ " mov rbp, rsp\n"
+ " push r15\n"
+ " push r14\n"
+ " mov r15, rax ; name\n"
+ " mov r14, r10 ; ppfn\n"
+ " push r9\n"
+ " push r8\n"
+ " push rcx\n"
+ " push rdx\n"
+ " push r12\n"
+ " %%ifdef ASM_CALL64_GCC\n"
+ " push rsi\n"
+ " push rdi\n"
+ " mov r12, rsp\n"
+ " %%else\n"
+ " mov r12, rsp\n"
+ " sub rsp, 20h\n"
+ " %%endif\n"
+ " and rsp, 0fffffff0h ; Try make sure the stack is aligned\n"
+ "\n"
+ " call NAME(LazyLoading) ; returns handle in rcx\n"
+ " %%ifdef ASM_CALL64_GCC\n"
+ " mov rdi, rcx ; hLdrMod\n"
+ " mov rsi, r15 ; pszSymbol\n"
+ " mov rdx, r14 ; ppvValue\n"
+ " %%else\n"
+ " mov rdx, r15 ; pszSymbol\n"
+ " mov r8, r14 ; ppvValue\n"
+ " %%endif\n"
+ " call IMP2(RTLdrGetSymbol)\n"
+ " or eax, eax\n"
+ ".badsym:\n"
+ " jz .symok\n"
+ " int3\n"
+ " jmp .badsym\n"
+ ".symok:\n"
+ "\n"
+ " mov rsp, r12\n"
+ " %%ifdef ASM_CALL64_GCC\n"
+ " pop rdi\n"
+ " pop rsi\n"
+ " %%endif\n"
+ " pop r12\n"
+ " pop rdx\n"
+ " pop rcx\n"
+ " pop r8\n"
+ " pop r9\n"
+ " pop r14\n"
+ " pop r15\n"
+ " leave\n"
+ "\n"
+ "%%elifdef RT_ARCH_X86\n"
+ " push ebp\n"
+ " mov ebp, esp\n"
+ " push eax\n"
+ " push ecx\n"
+ " push edx\n"
+ " and esp, 0fffffff0h\n"
+ "\n"
+ ".loaded:\n"
+ " mov eax, [ebp + 4] ; value addr\n"
+ " push eax\n"
+ " mov edx, [ebp + 8] ; symbol name\n"
+ " push edx\n"
+ " call NAME(LazyLoading) ; returns handle in ecx\n"
+ " mov ecx, [g_hMod]\n"
+ " call IMP2(RTLdrGetSymbol)\n"
+ " or eax, eax\n"
+ ".badsym:\n"
+ " jz .symok\n"
+ " int3\n"
+ " jmp .badsym\n"
+ ".symok:\n"
+ " lea esp, [ebp - 0ch]\n"
+ " pop edx\n"
+ " pop ecx\n"
+ " pop eax\n"
+ " leave\n"
+ "%%else\n"
+ " %%error \"Unsupported architecture\"\n"
+ "%%endif\n"
+ " ret\n"
+ "ENDPROC LazyLoadResolver\n"
+ );
+
+ return RTEXITCODE_SUCCESS;
+}
+
+
+/**
+ * Generates the assembly source code, writing it to g_pszOutput.
+ *
+ * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE, in the latter case full
+ * details has been displayed.
+ */
+static RTEXITCODE generateOutput(void)
+{
+ RTEXITCODE rcExit = RTEXITCODE_FAILURE;
+ FILE *pOutput = fopen(g_pszOutput, "w");
+ if (pOutput)
+ {
+ rcExit = generateOutputInner(pOutput);
+ if (fclose(pOutput))
+ {
+ fprintf(stderr, "error: Error closing '%s'.\n", g_pszOutput);
+ rcExit = RTEXITCODE_FAILURE;
+ }
+ }
+ else
+ fprintf(stderr, "error: Failed to open '%s' for writing.\n", g_pszOutput);
+ return rcExit;
+}
+
+
+/**
+ * Displays usage information.
+ *
+ * @returns RTEXITCODE_SUCCESS.
+ * @param pszArgv0 The argv[0] string.
+ */
+static int usage(const char *pszArgv0)
+{
+ printf("usage: %s --libary <loadname> --output <lazyload.asm> <input.def>\n"
+ "\n"
+ "Copyright (C) 2013 Oracle Corporation\n"
+ , pszArgv0);
+
+ return RTEXITCODE_SUCCESS;
+}
+
+
+int main(int argc, char **argv)
+{
+ /*
+ * Parse options.
+ */
+ for (int i = 1; i < argc; i++)
+ {
+ const char *psz = argv[i];
+ if (*psz == '-')
+ {
+ if (!strcmp(psz, "--output") || !strcmp(psz, "-o"))
+ {
+ if (++i >= argc)
+ {
+ fprintf(stderr, "syntax error: File name expected after '%s'.\n", psz);
+ return RTEXITCODE_SYNTAX;
+ }
+ g_pszOutput = argv[i];
+ }
+ else if (!strcmp(psz, "--library") || !strcmp(psz, "-l"))
+ {
+ if (++i >= argc)
+ {
+ fprintf(stderr, "syntax error: Library name expected after '%s'.\n", psz);
+ return RTEXITCODE_SYNTAX;
+ }
+ g_pszLibrary = argv[i];
+ }
+ /** @todo Support different load methods so this can be used on system libs and
+ * such if we like. */
+ else if ( !strcmp(psz, "--help")
+ || !strcmp(psz, "-help")
+ || !strcmp(psz, "-h")
+ || !strcmp(psz, "-?") )
+ return usage(argv[0]);
+ else if ( !strcmp(psz, "--version")
+ || !strcmp(psz, "-V"))
+ {
+ printf("$Revision: 87893 $\n");
+ return RTEXITCODE_SUCCESS;
+ }
+ else
+ {
+ fprintf(stderr, "syntax error: Unknown option '%s'.\n", psz);
+ return RTEXITCODE_SYNTAX;
+ }
+ }
+ else
+ {
+ if (g_pszInput)
+ {
+ fprintf(stderr, "syntax error: Already specified '%s' as the input file.\n", g_pszInput);
+ return RTEXITCODE_SYNTAX;
+ }
+ g_pszInput = argv[i];
+ }
+ }
+ if (!g_pszInput)
+ {
+ fprintf(stderr, "syntax error: No input file specified.\n");
+ return RTEXITCODE_SYNTAX;
+ }
+ if (!g_pszOutput)
+ {
+ fprintf(stderr, "syntax error: No output file specified.\n");
+ return RTEXITCODE_SYNTAX;
+ }
+ if (!g_pszLibrary)
+ {
+ fprintf(stderr, "syntax error: No library name specified.\n");
+ return RTEXITCODE_SYNTAX;
+ }
+
+ /*
+ * Do the job.
+ */
+ RTEXITCODE rcExit = parseInput();
+ if (rcExit == RTEXITCODE_SUCCESS)
+ rcExit = generateOutput();
+ return rcExit;
+}
+
diff --git a/src/bldprogs/VBoxTpG.cpp b/src/bldprogs/VBoxTpG.cpp
index 9c0d851a..d7a71c5b 100644
--- a/src/bldprogs/VBoxTpG.cpp
+++ b/src/bldprogs/VBoxTpG.cpp
@@ -483,11 +483,15 @@ static RTEXITCODE generateAssembly(PSCMSTREAM pStrm)
" [section __VTG __VTGObj align=16]\n"
"VTG_GLOBAL g_aVTGObj_LinkerPleaseNoticeMe, data\n"
" [section __VTG __VTGPrLc.Begin align=16]\n"
+ " dq 0, 0 ; Paranoia, related to the fudge below.\n"
"VTG_GLOBAL g_aVTGPrLc, data\n"
" [section __VTG __VTGPrLc align=16]\n"
"VTG_GLOBAL g_aVTGPrLc_LinkerPleaseNoticeMe, data\n"
" [section __VTG __VTGPrLc.End align=16]\n"
"VTG_GLOBAL g_aVTGPrLc_End, data\n"
+ " dq 0, 0 ; Fudge to work around unidentified linker where it would otherwise generate\n"
+ " ; a fix up of the first dword in __VTGPrLc.Begin despite the fact that it were\n"
+ " ; an empty section with nothing whatsoever to fix up.\n"
" %%endif\n"
" [section __VTG __VTGObj]\n"
"\n"
@@ -782,22 +786,21 @@ static RTEXITCODE generateAssembly(PSCMSTREAM pStrm)
* Emit code for the stub functions.
*/
bool const fWin64 = g_cBits == 64 && (!strcmp(g_pszAssemblerFmtVal, "win64") || !strcmp(g_pszAssemblerFmtVal, "pe64"));
- bool const fMachO64 = g_cBits == 64 && !strcmp(g_pszAssemblerFmtVal, "macho64");
- bool const fMachO32 = g_cBits == 32 && !strcmp(g_pszAssemblerFmtVal, "macho32");
+ bool const fElf = !strcmp(g_pszAssemblerFmtVal, "elf32") || !strcmp(g_pszAssemblerFmtVal, "elf64");
ScmStreamPrintf(pStrm,
"\n"
";\n"
"; Prob stubs.\n"
";\n"
"BEGINCODE\n"
- "extern %sNAME(%s)\n",
- g_fProbeFnImported ? "IMP" : "",
- g_pszProbeFnName);
- if (fMachO64 && g_fProbeFnImported && !g_fPic)
+ );
+ if (g_fProbeFnImported)
ScmStreamPrintf(pStrm,
- "g_pfnVtgProbeFn:\n"
- " dq NAME(%s)\n",
+ "EXTERN_IMP2 %s\n"
+ "BEGINCODE ; EXTERN_IMP2 changes section\n",
g_pszProbeFnName);
+ else
+ ScmStreamPrintf(pStrm, "extern NAME(%s)\n", g_pszProbeFnName);
RTListForEach(&g_ProviderHead, pProvider, VTGPROVIDER, ListEntry)
{
@@ -835,7 +838,7 @@ static RTEXITCODE generateAssembly(PSCMSTREAM pStrm)
* Jump to the fire-probe function.
*/
if (g_cBits == 32)
- ScmStreamPrintf(pStrm, g_fPic ?
+ ScmStreamPrintf(pStrm, g_fPic && fElf ?
" jmp %s wrt ..plt\n"
: g_fProbeFnImported ?
" mov ecx, IMP2(%s)\n"
@@ -843,22 +846,11 @@ static RTEXITCODE generateAssembly(PSCMSTREAM pStrm)
:
" jmp NAME(%s)\n"
, g_pszProbeFnName);
- else if (fWin64)
- ScmStreamPrintf(pStrm, g_fProbeFnImported ?
- " mov rax, IMP2(%s)\n"
- " jmp rax\n"
- :
- " jmp NAME(%s)\n"
- , g_pszProbeFnName);
- else if (fMachO64 && g_fProbeFnImported)
- ScmStreamPrintf(pStrm,
- " jmp [g_pfnVtgProbeFn wrt rip]\n");
else
- ScmStreamPrintf(pStrm, g_fPic ?
+ ScmStreamPrintf(pStrm, g_fPic && fElf ?
" jmp [rel %s wrt ..got]\n"
: g_fProbeFnImported ?
- " lea rax, [IMP2(%s)]\n"
- " jmp rax\n"
+ " jmp IMP2(%s)\n"
:
" jmp NAME(%s)\n"
, g_pszProbeFnName);
@@ -2320,7 +2312,7 @@ static RTEXITCODE parseArguments(int argc, char **argv)
case 'V':
{
/* The following is assuming that svn does it's job here. */
- static const char s_szRev[] = "$Revision: 80390 $";
+ static const char s_szRev[] = "$Revision: 87697 $";
const char *psz = RTStrStripL(strchr(s_szRev, ' '));
RTPrintf("r%.*s\n", strchr(psz, ' ') - psz, psz);
return RTEXITCODE_SUCCESS;
diff --git a/src/bldprogs/bin2c.c b/src/bldprogs/bin2c.c
index a0a973ce..23e07496 100644
--- a/src/bldprogs/bin2c.c
+++ b/src/bldprogs/bin2c.c
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/bldprogs/biossums.c b/src/bldprogs/biossums.c
index e179f649..aa02a2f9 100644
--- a/src/bldprogs/biossums.c
+++ b/src/bldprogs/biossums.c
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/src/bldprogs/checkUndefined.sh b/src/bldprogs/checkUndefined.sh
index aeca4f9d..389ddf75 100755
--- a/src/bldprogs/checkUndefined.sh
+++ b/src/bldprogs/checkUndefined.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# Copyright (C) 2006-2010 Oracle Corporation
+# Copyright (C) 2006-2013 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
@@ -14,11 +14,12 @@
#
# Compare undefined symbols in a shared or static object against a new-line
-# separated list of grep patterns in a text file.
+# separated list of grep patterns in a set of text files and complain if
+# symbols are found which aren't in the files.
#
-# Usage: /bin/sh <script name> <object> <allowed undefined symbols> [--static]
+# Usage: /bin/sh <script name> <object> [--static] <undefined symbol file...>
#
-# Currently only works for native objects on Linux platforms
+# Currently only works for native objects on Linux (and Solaris?) platforms.
#
echoerr()
@@ -26,28 +27,31 @@ echoerr()
echo $* 1>&2
}
-hostos=$1
-target=$2
-symbols=$3
-static=$4
-
-if test $# -lt 3 || test $# -gt 4 || test ! -r "$target" || test ! -r "$symbols"; then
- if test ! -r "$target"; then
- echoerr "$0: '$target' not readable"
- elif test ! -r "$symbols"; then
- echoerr "$0: '$symbols' not readable"
- else
- echoerr "$0: Wrong number of arguments"
- fi
- args_ok="no"
+hostos="${1}"
+target="${2}"
+shift 2
+if test "${1}" = "--static"; then
+ static="${1}"
+ shift
fi
-if test $# -eq 4 && test "$static" != "--static"; then
- args_ok="no"
+if test $# -lt 1; then
+ echoerr "${0}: Wrong number of arguments"
+ args_ok="no"
+fi
+if test ! -r "${target}"; then
+ echoerr "${0}: '${target}' not readable"
+ args_ok="no"
fi
+for i in "${@}"; do
+ if test ! -r "${i}"; then
+ echoerr "${0}: '${i}' not readable"
+ args_ok="no"
+ fi
+done
if test "$args_ok" = "no"; then
- echoerr "Usage: $0 <object> <allowed undefined symbols> [--static]"
+ echoerr "Usage: $0 <object> [--static] <undefined symbol file...>"
exit 1
fi
@@ -67,17 +71,20 @@ if test "$static" = "--static"; then
command="-t"
fi
-if test ! -x "$objdumpbin"; then
- echoerr "$0: '$objdumpbin' not found or not executable."
+if test ! -x "${objdumpbin}"; then
+ echoerr "${0}: '${objdumpbin}' not found or not executable."
exit 1
fi
-undefined=`$objdumpbin $command $target | $grepbin '*UND*' | $grepbin -v -f $symbols | kmk_sed -e 's/^.*[[:blank:]]\(.*\)/\1/'`
+undefined=`"${objdumpbin}" ${command} "${target}" | kmk_sed -n 's/.*\*UND\*.*\s\([:graph:]*\)/\1/p'`
+for i in "${@}"; do
+ undefined=`echo "${undefined}" | "${grepbin}" -w -v -f "${i}"`
+done
num_undef=`echo $undefined | wc -w`
if test $num_undef -ne 0; then
- echoerr "$0: following symbols not defined in $symbols:"
- echoerr "$undefined"
+ echoerr "${0}: following symbols not defined in the files ${@}:"
+ echoerr "${undefined}"
exit 1
fi
# Return code
diff --git a/src/bldprogs/filesplitter.cpp b/src/bldprogs/filesplitter.cpp
index 487e044d..9c88bcd3 100644
--- a/src/bldprogs/filesplitter.cpp
+++ b/src/bldprogs/filesplitter.cpp
@@ -39,7 +39,7 @@
/**
* Calculates the line number for a file position.
- *
+ *
* @returns Line number.
* @param pcszContent The file content.
* @param pcszPos The current position.
@@ -47,7 +47,7 @@
static unsigned long lineNumber(const char *pcszContent, const char *pcszPos)
{
unsigned long cLine = 0;
- while ( *pcszContent
+ while ( *pcszContent
&& (uintptr_t)pcszContent < (uintptr_t)pcszPos)
{
pcszContent = strchr(pcszContent, '\n');
@@ -62,8 +62,8 @@ static unsigned long lineNumber(const char *pcszContent, const char *pcszPos)
/**
- * Writes an error message.
- *
+ * Writes an error message.
+ *
* @returns RTEXITCODE_FAILURE.
* @param pcszFormat Error message.
* @param ... Format argument referenced in the message.
@@ -82,8 +82,8 @@ static int printErr(const char *pcszFormat, ...)
/**
- * Opens the makefile list for writing.
- *
+ * Opens the makefile list for writing.
+ *
* @returns Exit code.
* @param pcszPath The path to the file.
* @param pcszVariableName The make variable name.
@@ -109,8 +109,8 @@ static int openMakefileList(const char *pcszPath, const char *pcszVariableName,
/**
- * Adds the given file to the makefile list.
- *
+ * Adds the given file to the makefile list.
+ *
* @returns Exit code.
* @param pFile The file stream of the makefile list.
* @param pszFilename The file name to add.
@@ -131,8 +131,8 @@ static int addFileToMakefileList(FILE *pFile, char *pszFilename)
/**
- * Closes the makefile list.
- *
+ * Closes the makefile list.
+ *
* @returns Exit code derived from @a rc.
* @param pFile The file stream of the makefile list.
* @param rc The current exit code.
@@ -147,8 +147,8 @@ static int closeMakefileList(FILE *pFile, int rc)
/**
- * Reads in a file.
- *
+ * Reads in a file.
+ *
* @returns Exit code.
* @param pcszFile The path to the file.
* @param ppszFile Where to return the buffer.
@@ -198,9 +198,9 @@ static int readFile(const char *pcszFile, char **ppszFile, size_t *pcchFile)
/**
- * Checks whether the sub-file already exists and has the exact
- * same content.
- *
+ * Checks whether the sub-file already exists and has the exact
+ * same content.
+ *
* @returns @c true if the existing file matches exactly, otherwise @c false.
* @param pcszFilename The path to the file.
* @param pcszSubContent The content to write.
@@ -208,7 +208,7 @@ static int readFile(const char *pcszFile, char **ppszFile, size_t *pcchFile)
*/
static bool compareSubFile(const char *pcszFilename, const char *pcszSubContent, size_t cchSubContent)
{
- struct stat FileStat;
+ struct stat FileStat;
if (stat(pcszFilename, &FileStat))
return false;
if ((size_t)FileStat.st_size < cchSubContent)
@@ -229,8 +229,8 @@ static bool compareSubFile(const char *pcszFilename, const char *pcszSubContent,
/**
- * Writes out a sub-file.
- *
+ * Writes out a sub-file.
+ *
* @returns exit code.
* @param pcszFilename The path to the sub-file.
* @param pcszSubContent The content of the file.
@@ -257,10 +257,10 @@ static int writeSubFile(const char *pcszFilename, const char *pcszSubContent, si
/**
* Does the actual file splitting.
- *
+ *
* @returns exit code.
* @param pcszOutDir Path to the output directory.
- * @param pcszContent The content to split up.
+ * @param pcszContent The content to split up.
* @param pFileList The file stream of the makefile list. Can be NULL.
*/
static int splitFile(const char *pcszOutDir, const char *pcszContent, FILE *pFileList)
@@ -291,13 +291,13 @@ static int splitFile(const char *pcszOutDir, const char *pcszContent, FILE *pFil
const char *pcszStartFilename = pcszBegin + cchBeginMarker;
const char *pcszEndQuote = (const char *)memchr(pcszStartFilename, '\"', pcszLineAfterBegin - pcszStartFilename);
if (!pcszEndQuote)
- return printErr("Can't parse filename after begin-file marker (line %lu).\n",
+ return printErr("Can't parse filename after begin-file marker (line %lu).\n",
lineNumber(pcszContent, s_szBeginMarker));
/* find end marker */
const char *pcszEnd = strstr(pcszLineAfterBegin, s_szEndMarker);
if (!pcszEnd)
- return printErr("No matching end-line marker for begin-file marker found (line %lu).\n",
+ return printErr("No matching end-line marker for begin-file marker found (line %lu).\n",
lineNumber(pcszContent, s_szBeginMarker));
/* construct output filename */
@@ -328,7 +328,7 @@ static int splitFile(const char *pcszOutDir, const char *pcszContent, FILE *pFil
pcszSearch = pcszEnd;
} while (rc == 0 && pcszSearch);
- printf("filesplitter: Out of %lu files: %lu rewritten, %lu unchanged. (%s)\n",
+ printf("filesplitter: Out of %lu files: %lu rewritten, %lu unchanged. (%s)\n",
cFilesWritten + cFilesUnchanged, cFilesWritten, cFilesUnchanged, pcszOutDir);
return rc;
}
diff --git a/src/bldprogs/preload.cpp b/src/bldprogs/preload.cpp
index 07def9a0..827a99c6 100644
--- a/src/bldprogs/preload.cpp
+++ b/src/bldprogs/preload.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -146,7 +146,7 @@ int main(int argc, char **argv)
if ( !strcmp(argv[i], "--version")
|| !strcmp(argv[i], "-V"))
{
- printf("$Revision: 60692 $\n");
+ printf("$Revision: 83575 $\n");
return 0;
}
fprintf(stderr, "syntax error: unknown option '%s'\n", argv[i]);
diff --git a/src/bldprogs/scm.cpp b/src/bldprogs/scm.cpp
index 5e5d69d1..4e4a2ebe 100644
--- a/src/bldprogs/scm.cpp
+++ b/src/bldprogs/scm.cpp
@@ -229,6 +229,16 @@ static PFNSCMREWRITER const g_aRewritersFor_BatchFiles[] =
rewrite_StripTrailingBlanks
};
+static PFNSCMREWRITER const g_aRewritersFor_Python[] =
+{
+ /** @todo rewrite_ForceLFIfExecutable */
+ rewrite_ExpandTabs,
+ rewrite_StripTrailingBlanks,
+ rewrite_AdjustTrailingLines,
+ rewrite_SvnKeywords
+};
+
+
static SCMCFGENTRY const g_aConfigs[] =
{
{ RT_ELEMENTS(g_aRewritersFor_Makefile_kup), &g_aRewritersFor_Makefile_kup[0], "Makefile.kup" },
@@ -238,6 +248,7 @@ static SCMCFGENTRY const g_aConfigs[] =
{ RT_ELEMENTS(g_aRewritersFor_RC), &g_aRewritersFor_RC[0], "*.rc" },
{ RT_ELEMENTS(g_aRewritersFor_ShellScripts), &g_aRewritersFor_ShellScripts[0], "*.sh|configure" },
{ RT_ELEMENTS(g_aRewritersFor_BatchFiles), &g_aRewritersFor_BatchFiles[0], "*.bat|*.cmd|*.btm|*.vbs|*.ps1" },
+ { RT_ELEMENTS(g_aRewritersFor_Python), &g_aRewritersFor_Python[0], "*.py" },
};
@@ -449,7 +460,7 @@ static int scmSettingsBaseHandleOpt(PSCMSETTINGSBASE pSettings, int rc, PRTGETOP
return VINF_SUCCESS;
return RTStrAAppendExN(ppsz, 2,
- "|", *ppsz && **ppsz ? 1 : 0,
+ "|", *ppsz && **ppsz ? (size_t)1 : (size_t)0,
pszSrc, cchSrc);
}
@@ -1529,7 +1540,7 @@ int main(int argc, char **argv)
case 'V':
{
/* The following is assuming that svn does it's job here. */
- static const char s_szRev[] = "$Revision: 78836 $";
+ static const char s_szRev[] = "$Revision: 89658 $";
const char *psz = RTStrStripL(strchr(s_szRev, ' '));
RTPrintf("r%.*s\n", strchr(psz, ' ') - psz, psz);
return 0;
diff --git a/src/bldprogs/scmstream.cpp b/src/bldprogs/scmstream.cpp
index 9ba78486..4a03ed9d 100644
--- a/src/bldprogs/scmstream.cpp
+++ b/src/bldprogs/scmstream.cpp
@@ -1358,5 +1358,3 @@ const char *ScmStreamCGetWordM1(PSCMSTREAM pStream, size_t *pcchWord)
return psz;
}
-
-
diff --git a/src/bldprogs/scmsubversion.cpp b/src/bldprogs/scmsubversion.cpp
index 35b56d57..34505e0d 100644
--- a/src/bldprogs/scmsubversion.cpp
+++ b/src/bldprogs/scmsubversion.cpp
@@ -1059,5 +1059,3 @@ int ScmSvnApplyChanges(PSCMRWSTATE pState)
#endif
}
-
-