0001
0002 #include <inttypes.h>
0003 #include <unistd.h>
0004 #include <stdio.h>
0005 #include <string.h>
0006 #include <internal/lib.h> // page_size
0007 #include "machine.h"
0008 #include "api/fs/fs.h"
0009 #include "debug.h"
0010 #include "symbol.h"
0011
0012 int arch__fix_module_text_start(u64 *start, u64 *size, const char *name)
0013 {
0014 u64 m_start = *start;
0015 char path[PATH_MAX];
0016
0017 snprintf(path, PATH_MAX, "module/%.*s/sections/.text",
0018 (int)strlen(name) - 2, name + 1);
0019 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
0020 pr_debug2("Using module %s start:%#lx\n", path, m_start);
0021 *start = m_start;
0022 } else {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 *size -= (*start - m_start);
0034 }
0035
0036 return 0;
0037 }