Задача 10 - мануал (1110760)
Текст из файла
Resolving Symbols406Relocating Code and Data407Practice problem 7.1 (pg 662)SYMBOL TABLE .symtabInfo about functions and global variablesthat are defined and referenced in aprogramDoes not contain entries for local variablesUnderstanding the relationship between linkersymbols and C variables/functions… notice that the Clocal variable temp does NOT have a symbol tableentry. Why? It goes on the stack!Symbolbufbufp0bufp1swaptempswap.o .symtab entry?yesyesyesyesnosymbol typeexternglobalglobalglobal---module where definedmain.oswap.oswap.oswap.o---section.data.data.bss.text--408Swap relocatable symbol table% objdump -r -d -t swap.oswap.o: file format elf32-i386SYMBOL TABLE:00000000 l df *ABS*00000000 swap.c00000000 l d .text00000000 .text00000000 l d .data00000000 .data00000000 l d .bss00000000 .bss00000000 l O .bss00000004 bufp100000000 g O .data00000004 bufp000000000 *UND*00000000 buf00000000 g F .text00000035 swapO = objectd = debugl = localF = functionf = fileg = global409Symbols and Symbol TablesLocal linker symbols != local program variables.symtab does not contain any symbols thatcorrespond to local non-static program variables.These are managed at run time on the stack and arenot of interest to the linkerHowever… local procedure variables that are definedwith the C static attribute (EXCEPTION) are notmanaged on the stack The compiler allocates space in .data or .bss for each andcreated a local linker symbol in the symbol table with aunique nameFYI: Static variable’s lifetime extends across the entire run ofthe program where local variables are allocated anddeallocated on the stack410SYMBOL TABLESBuilt by assemblers using symbols exported by thecompiler into the .s fileAn ELF symbol table is contained in the .symtabsectionIt contains an array of entries where each entrycontains:Symbol’s value i.e.
addressFlag bits (l=local, g = global, F=function, etc) Characters and spaces – up to 7 bitsSection or *ABS* (absolute – not in any section) *UND* if referenced but not definedAlignment or sizeSymbol’s name411RelocationRelocation merges the input modules and assigns runtime addresses to each symbolWhen an assembler generates an object module, itdoes not know where the code and data willultimately be stored in memory or the locations of anyexternally defined functions or global variablesreferenced by the moduleA “relocation entry” is generated when the assemblerencounters a reference to an object who ultimatelocation is unknown2 typesR_386_PC32R_386_324122 Relocation typesR_386_PC32relocate a reference that uses a 32-bit PC-relativeaddress.Effective address = PC + instruction encoded addrR_386_32Absolute addressingUses the value encoded in the instruction413Relocation Info% gcc –c –m32 main.c% objdump -r -tdata main.o% gcc -o main -m32 main.c/tmp/ccEVrEUg.o:In function `main':main.c:(.text+0x7): undefinedreference to `swap'collect2:ld returned 1 exit statusCall instruction @ offset 0x6,opcode e8, 32-bit ref (-4)Offset = 0x7 Symbol = swapType = R_386_PC32SYMBOL TABLE:00000000 l df *ABS*00000000 l d .text00000000 l d .data00000000 l d .bss00000000 g O .data00000000 g F .text00000000*UND*00000000 main.c00000000 .text00000000 .data00000000 .bss00000008 buf00000014 main00000000 swapNOTE: relocationentries andinstructions arestored in differentsections of the objectfile .rel.txt vs .text.text + .offset0x80483b4 + 0x7= 0x80483bb = ref addrDisassembly of section .text: 0x80483b400000000 <main>:0x80483c80:55push %ebp1:89 e5mov %esp,%ebpcall swap3:83 e4 f0and $0xfffffff0,%esp6:e8 fc ff ff ff call 7 <main+0x7>Relocation7: R_386_PC32 swapentryb:b8 00 00 00 00 mov $0x0,%eax10:89 ecmov %ebp,%esp12:5dpop %ebp .symbol swap + 32-bit ref – ref addr13:c3ret0x80483c8 + -4 - 0x80483bb = 0x9414Executable before/after relocationReturn addressLocation of swap functionR_386_PC32relocate areference thatuses a 32-bitPC-relativeaddress.Effective address= PC + instructionencoded address.text + .offset = 0x8048380 + 0x12 = 0x8048392 reference addressCall + 32-bit ref – reference address = 0x80483b0 + -4 – 0x8048392 = 0x1a415.
Характеристики
Тип файла PDF
PDF-формат наиболее широко используется для просмотра любого типа файлов на любом устройстве. В него можно сохранить документ, таблицы, презентацию, текст, чертежи, вычисления, графики и всё остальное, что можно показать на экране любого устройства. Именно его лучше всего использовать для печати.
Например, если Вам нужно распечатать чертёж из автокада, Вы сохраните чертёж на флешку, но будет ли автокад в пункте печати? А если будет, то нужная версия с нужными библиотеками? Именно для этого и нужен формат PDF - в нём точно будет показано верно вне зависимости от того, в какой программе создали PDF-файл и есть ли нужная программа для его просмотра.