eliminate LoaderUtils.h
Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I662714ee4faa6485d2ba7bbcbc8e34c76e37b091
This commit is contained in:
parent
23c436f957
commit
f7c0d993dd
2 changed files with 18 additions and 42 deletions
|
|
@ -29,7 +29,6 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "../progs/include/bpf_map_def.h"
|
||||
#include "LoaderUtils.h"
|
||||
#include "bpf/BpfUtils.h"
|
||||
#include "include/libbpf_android.h"
|
||||
|
||||
|
|
@ -60,6 +59,17 @@ using std::vector;
|
|||
namespace android {
|
||||
namespace bpf {
|
||||
|
||||
static string pathToFilename(const string& path, bool noext = false) {
|
||||
vector<string> spath = android::base::Split(path, "/");
|
||||
string ret = spath.back();
|
||||
|
||||
if (noext) {
|
||||
size_t lastindex = ret.find_last_of('.');
|
||||
return ret.substr(0, lastindex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
enum bpf_prog_type type;
|
||||
|
|
@ -252,7 +262,7 @@ static string getSectionName(enum bpf_prog_type type)
|
|||
{
|
||||
for (int i = 0; sectionNameTypes[i].type != BPF_PROG_TYPE_UNSPEC; i++)
|
||||
if (sectionNameTypes[i].type == type)
|
||||
return std::string(sectionNameTypes[i].name);
|
||||
return string(sectionNameTypes[i].name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -264,7 +274,7 @@ static bool isRelSection(codeSection& cs, string& name) {
|
|||
|
||||
if (st.type != cs.type) continue;
|
||||
|
||||
if (StartsWith(name, std::string(".rel") + st.name + "/"))
|
||||
if (StartsWith(name, string(".rel") + st.name + "/"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
@ -352,7 +362,10 @@ static int readCodeSections(ifstream& elfFile, vector<codeSection>& cs) {
|
|||
enum bpf_prog_type ptype = getSectionType(name);
|
||||
if (ptype != BPF_PROG_TYPE_UNSPEC) {
|
||||
string oldName = name;
|
||||
deslash(name);
|
||||
|
||||
// convert all slashes to underscores
|
||||
std::replace(name.begin(), name.end(), '/', '_');
|
||||
|
||||
cs_temp.type = ptype;
|
||||
cs_temp.name = name;
|
||||
|
||||
|
|
@ -578,7 +591,7 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const
|
|||
cs[i].name.c_str(), fd, (fd < 0 ? std::strerror(errno) : "no error"));
|
||||
|
||||
if (fd < 0) {
|
||||
std::vector<std::string> lines = android::base::Split(log_buf.data(), "\n");
|
||||
vector<string> lines = android::base::Split(log_buf.data(), "\n");
|
||||
|
||||
ALOGW("bpf_prog_load - BEGIN log_buf contents:");
|
||||
for (const auto& line : lines) ALOGW("%s", line.c_str());
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <android-base/strings.h>
|
||||
|
||||
static std::string pathToFilename(const std::string& path, bool noext = false) {
|
||||
std::vector<std::string> spath = android::base::Split(path, "/");
|
||||
std::string ret = spath.back();
|
||||
|
||||
if (noext) {
|
||||
size_t lastindex = ret.find_last_of('.');
|
||||
return ret.substr(0, lastindex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void deslash(std::string& s) {
|
||||
std::replace(s.begin(), s.end(), '/', '_');
|
||||
}
|
||||
Loading…
Reference in a new issue