Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2478)

Unified Diff: src/trusted/service_runtime/sel_load_image.c

Issue 389022: first step in factoring out code dealing with elf into a separate library.... (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/service_runtime/sel_ldr_standard.c ('k') | src/trusted/service_runtime/sel_main.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/sel_load_image.c
===================================================================
--- src/trusted/service_runtime/sel_load_image.c (revision 1006)
+++ src/trusted/service_runtime/sel_load_image.c (working copy)
@@ -1,84 +0,0 @@
-/*
- * Copyright 2008, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * NaCl Simple/secure ELF loader (NaCl SEL).
- */
-
-#include "native_client/src/trusted/service_runtime/sel_ldr.h"
-
-
-NaClErrorCode NaClLoadImage(struct Gio *gp,
- struct NaClApp *nap) {
- int segnum;
- Elf32_Phdr *php;
- uintptr_t paddr;
- uintptr_t end_vaddr;
-
- for (segnum = 0; segnum < nap->elf_hdr.e_phnum; ++segnum) {
- php = &nap->phdrs[segnum];
-
- /* did we decide that we will load this segment earlier? */
- if (0 == (php->p_flags & PF_OS_WILL_LOAD)) {
- continue;
- }
-
- end_vaddr = php->p_vaddr + php->p_filesz;
- /* integer overflow? */
- if (end_vaddr < php->p_vaddr) {
- NaClLog(LOG_FATAL, "parameter error should have been detected already\n");
- }
- /*
- * is the end virtual address within the NaCl application's
- * address space? if it is, it implies that the start virtual
- * address is also.
- */
- if (end_vaddr >= (1U << nap->addr_bits)) {
- NaClLog(LOG_FATAL, "parameter error should have been detected already\n");
- }
-
- paddr = nap->mem_start + php->p_vaddr;
-
- if ((*gp->vtbl->Seek)(gp, php->p_offset, SEEK_SET) == -1) {
- return LOAD_SEGMENT_BAD_PARAM;
- }
- if ((Elf32_Word) (*gp->vtbl->Read)(gp, (void *) paddr, php->p_filesz)
- != php->p_filesz) {
- return LOAD_SEGMENT_BAD_PARAM;
- }
- /* region from p_filesz to p_memsz should already be zero filled */
- }
-
- NaClFillEndOfTextRegion(nap);
-
- return LOAD_OK;
-}
-
« no previous file with comments | « src/trusted/service_runtime/sel_ldr_standard.c ('k') | src/trusted/service_runtime/sel_main.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698