object_file.cc (11793:ef606668d247) object_file.cc (13982:175e05a8ee6a)
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 26 unchanged lines hidden (view full) ---

35#include <sys/mman.h>
36#include <sys/types.h>
37#include <unistd.h>
38#include <zlib.h>
39
40#include <cstdio>
41#include <list>
42#include <string>
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 26 unchanged lines hidden (view full) ---

35#include <sys/mman.h>
36#include <sys/types.h>
37#include <unistd.h>
38#include <zlib.h>
39
40#include <cstdio>
41#include <list>
42#include <string>
43#include <vector>
43
44#include "base/cprintf.hh"
45#include "base/loader/aout_object.hh"
46#include "base/loader/dtb_object.hh"
47#include "base/loader/ecoff_object.hh"
48#include "base/loader/elf_object.hh"
49#include "base/loader/raw_object.hh"
50#include "base/loader/symtab.hh"

--- 41 unchanged lines hidden (view full) ---

92bool
93ObjectFile::loadSections(PortProxy& mem_proxy, Addr addr_mask, Addr offset)
94{
95 return (loadSection(&text, mem_proxy, addr_mask, offset)
96 && loadSection(&data, mem_proxy, addr_mask, offset)
97 && loadSection(&bss, mem_proxy, addr_mask, offset));
98}
99
44
45#include "base/cprintf.hh"
46#include "base/loader/aout_object.hh"
47#include "base/loader/dtb_object.hh"
48#include "base/loader/ecoff_object.hh"
49#include "base/loader/elf_object.hh"
50#include "base/loader/raw_object.hh"
51#include "base/loader/symtab.hh"

--- 41 unchanged lines hidden (view full) ---

93bool
94ObjectFile::loadSections(PortProxy& mem_proxy, Addr addr_mask, Addr offset)
95{
96 return (loadSection(&text, mem_proxy, addr_mask, offset)
97 && loadSection(&data, mem_proxy, addr_mask, offset)
98 && loadSection(&bss, mem_proxy, addr_mask, offset));
99}
100
101namespace
102{
103
104typedef std::vector<ObjectFile::Loader *> LoaderList;
105
106LoaderList &
107object_file_loaders()
108{
109 static LoaderList loaders;
110 return loaders;
111}
112
113} // anonymous namespace
114
115ObjectFile::Loader::Loader()
116{
117 object_file_loaders().emplace_back(this);
118}
119
120Process *
121ObjectFile::tryLoaders(ProcessParams *params, ObjectFile *obj_file)
122{
123 for (auto &loader: object_file_loaders()) {
124 Process *p = loader->load(params, obj_file);
125 if (p)
126 return p;
127 }
128
129 return nullptr;
130}
131
100static bool
101hasGzipMagic(int fd)
102{
103 uint8_t buf[2] = {0};
104 size_t sz = pread(fd, buf, 2, 0);
105 panic_if(sz != 2, "Couldn't read magic bytes from object file");
106 return ((buf[0] == 0x1f) && (buf[1] == 0x8b));
107}

--- 106 unchanged lines hidden ---
132static bool
133hasGzipMagic(int fd)
134{
135 uint8_t buf[2] = {0};
136 size_t sz = pread(fd, buf, 2, 0);
137 panic_if(sz != 2, "Couldn't read magic bytes from object file");
138 return ((buf[0] == 0x1f) && (buf[1] == 0x8b));
139}

--- 106 unchanged lines hidden ---