1
2#include <inttypes.h>
3#include <unistd.h>
4#include <stdio.h>
5#include <string.h>
6#include <internal/lib.h>
7#include "machine.h"
8#include "api/fs/fs.h"
9#include "debug.h"
10#include "symbol.h"
11
12int arch__fix_module_text_start(u64 *start, u64 *size, const char *name)
13{
14 u64 m_start = *start;
15 char path[PATH_MAX];
16
17 snprintf(path, PATH_MAX, "module/%.*s/sections/.text",
18 (int)strlen(name) - 2, name + 1);
19 if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
20 pr_debug2("Using module %s start:%#lx\n", path, m_start);
21 *start = m_start;
22 } else {
23
24
25
26
27
28
29
30
31
32
33 *size -= (*start - m_start);
34 }
35
36 return 0;
37}
38
39
40
41
42
43
44
45void arch__symbols__fixup_end(struct symbol *p, struct symbol *c)
46{
47 if (strchr(p->name, '[') == NULL && strchr(c->name, '['))
48
49 p->end = roundup(p->end, page_size);
50 else
51 p->end = c->start;
52 pr_debug4("%s sym:%s end:%#" PRIx64 "\n", __func__, p->name, p->end);
53}
54