Which requires text relocation




















On the SPARC platform, relocation entries apply to bytes byte8 , half-words half16 , or words the others. These values use the same byte order as other word values in the x86 architecture:. The relocation type specifies which bits to change and how to calculate their values. Calculations for the following relocation types assume the actions are transforming a relocatable file into either an executable or a shared object file.

Conceptually, the link-editor merges one or more relocatable files to form the output. The link-editor first decides how to combine and locate the input files. Then it updates the symbol values. Finally the link-editor performs the relocation. Relocations applied to executable or shared object files are similar and accomplish the same result. Descriptions in the tables in this section use the following notation:. The base address at which a shared object is loaded into memory during execution.

Generally, a shared object file is built with a 0 base virtual address, but the execution address is different.

See Program Header. The offset into the global offset table at which the address of the relocation entry's symbol resides during execution. The address of the global offset table. The section offset or address of the procedure linkage table entry for a symbol. Field names in the following table tell whether the relocation type checks for overflow. A calculated relocation value can be larger than the intended field, and a relocation type can verify V the value fits or truncate T the result.

As an example, V-simm13 means that the computed value can not have significant, nonzero bits outside the simm13 field. Why are the register adresses stored in the opcode,.

Also the value field of their relocation table entries is entirely unclear to me. I would have expected the. No, the linker is no longer involved with this. The relocation tables tell the loader , the part of the operating system that's responsible for loading the executable image into memory about the addresses.

The linker builds the executable image based on the assumption that everything is ideal and the image can be loaded at the intended address. If that's the case then everything is hunky-dory, nothing needs to be done. If there's a conflict however, the virtual address space is already in use by something else, then the image needs to be relocated at a different address.

That requires addresses to be patched, the offset between the ideal and the actual load address needs to be added. So if the. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. The function doAlmostNothing calls the exported function doNothing and statically linked function doNothingStatic. On the contrary, doNothing can be reference by another object file and used when linking an executable.

To produce an executable, the link-editor will have to place a doNothing somewhere and replace all the reference to it by its effective address. Looking at offset 17, we can see the call to doNothingStatic. This function is local to the file, so its offset can be directly written. Due to little-endianess of x86 architecture, 0xffffffe4 is -1c bytes from the next instruction pointer value which is 0x1c.

Hence, this is a call to the function written at address 0x0 which is doNothingStatic. On the contrary, the compiler did not put the address of the doNothing function, although he could give an address if he assumes the code is linearly mapped in memory.

I keep this question for latter. Anyway this gives us the opportunity to explain a basic relocation. If we only look at the bytes in the assembler code the translation in readable assembler code makes use of the sections we will describe now to show which function is called , we can see the 4 bytes 32 bits are zeros.

It will be the role of the linker to fill such portion of the assembler code with correct values when the object file has to be used. But the linker cannot magically guess which values to put in the final binary file. The compiler will put some information in ELF sections that are dedicated to the relocations: depending on the targeted architecture, the involved section are.

This is due to the commit. This does not change anything for static linkage explanation and mentioning the PLT now would be confusing: go to the dynamic link paragraph to know more about the PLT. The type of relocation tells the linker how to calculate the effective address. There are a few interesting things to say about the main function. The linker also operated a relocation to the doAlmostNothing function.

Let us see the relocation information from the object file containing the main function:. The undefined symbol doAlmostNothing will have to be relocated. We will see later that in the case of a position-independent code, the call to a function be done through a table called the Procedure Linkage Table which is used by the dynamic linker at runtime.

The link-editor builds the initial procedure linkage table, and the runtime linker modifies the entries during execution. SPARC relocation entries apply to bytes byte8 , half-words half16 , or words the others. IA relocation entries apply to words. The relocation type specifies which bits to change and how to calculate their values. In all cases the addend and the computed result use the same byte order. Field names in the following table tell whether the relocation type checks for overflow.

A calculated relocation value can be larger than the intended field, and a relocation type can verify V the value fits or truncate T the result.

As an example, V-simm13 means that the computed value can not have significant, nonzero bits outside the simm13 field. The link-editor creates this relocation type for dynamic linking. Its offset member refers to a location in a writable segment.

The symbol table index specifies a symbol that should exist both in the current object file and in a shared object. During execution, the runtime linker copies data associated with the shared object's symbol to the location specified by the offset.

See "Copy Relocations" for more details. The special relocation type allows you to determine the correspondence between symbols and global offset table entries. Its offset member gives the location of a procedure linkage table entry.

The runtime linker modifies the procedure linkage table entry to transfer control to the designated symbol address. Its offset member gives the location within a shared object that contains a value representing a relative address.



0コメント

  • 1000 / 1000