arch/x86/tools/relocs.c

Source file repositories/reference/linux-study-clean/arch/x86/tools/relocs.c

File Facts

System
Linux kernel
Corpus path
arch/x86/tools/relocs.c
Extension
.c
Size
25744 bytes
Lines
1080
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct relocs {
				uint32_t	*offset;
				unsigned long	count;
				unsigned long	size;
};

static struct relocs		relocs16;
static struct relocs		relocs32;

#if ELF_BITS == 64
static struct relocs		relocs64;
# define FMT PRIu64

#ifndef R_X86_64_REX_GOTPCRELX
# define R_X86_64_REX_GOTPCRELX 42
#endif

#else
# define FMT PRIu32
#endif

struct section {
				Elf_Shdr       shdr;
				struct section *link;
				Elf_Sym        *symtab;
				Elf32_Word     *xsymtab;
				Elf_Rel        *reltab;
				char           *strtab;
};
static struct section		*secs;

static const char * const	sym_regex_kernel[S_NSYMTYPES] = {
/*
 * Following symbols have been audited. There values are constant and do
 * not change if bzImage is loaded at a different physical address than
 * the address for which it has been compiled. Don't warn user about
 * absolute relocations present w.r.t these symbols.
 */
	[S_ABS] =
	"^(xen_irq_disable_direct_reloc$|"
	"xen_save_fl_direct_reloc$|"
	"xen_elfnote_.+_offset$|"
	"VDSO|"
	"__kcfi_typeid_|"
	"__crc_)",

/*
 * These symbols are known to be relative, even if the linker marks them
 * as absolute (typically defined outside any section in the linker script.)
 */
	[S_REL] =
	"^(__init_(begin|end)|"
	"__x86_cpu_dev_(start|end)|"
	"__alt_instructions(_end)?|"
	"(__iommu_table|__apicdrivers|__smp_locks)(_end)?|"
	"__(start|end)_pci_.*|"
#if CONFIG_FW_LOADER
	"__(start|end)_builtin_fw|"
#endif
	"__(start|stop)___ksymtab(_gpl)?|"
	"__(start|stop)___kcrctab(_gpl)?|"
	"__(start|stop)___param|"
	"__(start|stop)___modver|"
	"__(start|stop)___bug_table|"
	"__tracedata_(start|end)|"
	"__(start|stop)_notes|"
	"__end_rodata|"
	"__end_rodata_aligned|"
	"__initramfs_start|"
	"(jiffies|jiffies_64)|"
#if ELF_BITS == 64
	"__end_rodata_hpage_align|"
#endif
	"_end)$"
};


static const char * const sym_regex_realmode[S_NSYMTYPES] = {
/*
 * These symbols are known to be relative, even if the linker marks them
 * as absolute (typically defined outside any section in the linker script.)
 */
	[S_REL] =
	"^pa_",

/*
 * These are 16-bit segment symbols when compiling 16-bit code.
 */
	[S_SEG] =
	"^real_mode_seg$",

Annotation

Implementation Notes