Reposition Absolute Reference (absolute reference relocation)

Source: Internet
Author: User

Reposition Absolute Reference (absolute reference relocation)

Or to undertake the previous program, in swap.c "int *bufp0 = &buf[0];" Bufp0 is initialized to a global array address, so it needs to relocate, details <PIC1> and <pic2>, r.offset=0xc, R.symbol=buf, r.type=r_386_32, relocation entries tell the compiler , this is an absolute 32-bit reference and must be relocated to point to the last buf.
<pic1, Objdump-rs swap.o>


<pic2, readelf-a swap.o >


<PIC3, Readelf-a p>


by analyzing the target file you can know the runtime address of the BUF, <pic3>, ADDR (r.symbol) =addr (BUF) =0x0804a014, and then relocate:
*refptr = (unsigned) (ADDR (R.symbol) + *refptr)
= (unsigned) (0x0804a014 + 0)
= (unsigned) (0x0804a014)

In the final executable target file, <pic4> See that the value stored in the bufp0 in 0x0804a028 is 0x0804a014 (small end).

<PIC4, objdump-d-j .data>





Reposition Absolute Reference (absolute reference relocation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.