System.map file. There are _text, _stext, _etext characters. As I understand it, _stext is a symbol, whose address is the beginning of the code section, and _etext is the end address. Then what is the difference between _text and _stext? And _stext comes after _text in the symbol table.

0000000001000000 A phys_startup_64 ffffffff81000000 T _text ffffffff81000000 T startup_64 ffffffff81000110 T secondary_startup_64 ffffffff810001a9 t verify_cpu ffffffff810002a0 T start_cpu0 ffffffff810002b5 t bad_address ffffffff810002b8 T _stext ffffffff81001000 T hypercall_page ... ffffffff81808730 T bad_from_user ffffffff81808736 t bad_to_user ffffffff81808e57 T _etext 
  • It depends on how these symbols are used in the linker script (* .ld). Put it here. - maestro
  • @maestro it turns out I saw this System.map. I do not know how to see the ld script. - Mike AJ
  • one
    No, this is the output file of the linker, which shows where variables, functions, constants, and other symbols are actually located. Need input file. It should be somewhere in the project directory. There must be something inside it: SECTION { ouptut; { file1(.text) . = . + 1000; file2(.text) . += 1000; file3(.text) } = 0x1234; } SECTION { ouptut; { file1(.text) . = . + 1000; file2(.text) . += 1000; file3(.text) } = 0x1234; } SECTION { ouptut; { file1(.text) . = . + 1000; file2(.text) . += 1000; file3(.text) } = 0x1234; } - maestro
  • Well or system.map then system.map . You can pull out some information from it. - maestro
  • one
    So you collected the code yourself? Is there a makefile there? There should be something like $(ELF_IMAGE) : $(OBJS) $(LINKER_SCRIPT) , where LINKER_SCRIPT is a symbol that has the path to the ld file somewhere. And for this fragment of the map file, little is clear. - maestro

1 answer 1

It turns out all these characters were defined in the ld linker script. (kernel / vmlinux.lds.S)

_text is the start address of the .text section. _stext is the address of the kernel code (immediately after the bootstrapping code).