Page MenuHomeFreeBSD

libdwarf: Add symbol value when processing .rela relocations
ClosedPublic

Authored by emaste on Feb 11 2015, 7:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 18, 4:11 AM
Unknown Object (File)
Wed, Dec 18, 3:21 AM
Unknown Object (File)
Tue, Dec 10, 1:28 PM
Unknown Object (File)
Mon, Dec 2, 11:56 PM
Unknown Object (File)
Oct 2 2024, 10:01 PM
Unknown Object (File)
Oct 2 2024, 1:00 PM
Unknown Object (File)
Sep 24 2024, 3:14 PM
Unknown Object (File)
Sep 22 2024, 8:29 AM

Details

Summary

In practice .rela debug relocations often use the the .debug_* sections as the symbol, which has the value 0:

Relocation section '.rela.debug_info' at offset 0xd18 contains 205 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000006  001a0000000a R_X86_64_32       0000000000000000 .debug_abbrev + 0
00000000000c  001e0000000a R_X86_64_32       0000000000000000 .debug_str + 0
000000000012  001e0000000a R_X86_64_32       0000000000000000 .debug_str + 45

so in those cases there is no difference if the symbol value is used in the relocation or not.

It is not always the case though:

000000000039  002700000001 R_X86_64_64       0000000000000010 xen_pci_driver + 0

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste retitled this revision from to libdwarf: Add symbol value when processing .rela relocations.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added a subscriber: Unknown Object (MLST).

See also D1819

kib edited edge metadata.

It looks fine, but definitely is extremely subtle. The dwarf_get_reloc_size() returns zero for non-abs relocations, so dwarf_write_{m.l}sb() does nothing for other relocation types.

This at least deserves explanation in a comment.

This revision is now accepted and ready to land.Feb 11 2015, 7:18 PM
rpaulo edited edge metadata.

I agree with kib that this deserves a comment. And perhaps add another comment in D1819 explaining why it isn't needed for .rel relocations.

emaste edited edge metadata.

explicitly skip _dwarf_write_* if size==0 and add comment explaining that means unknown or non-absolute relocation

This revision now requires review to proceed.Feb 11 2015, 7:37 PM
kib edited edge metadata.
This revision is now accepted and ready to land.Feb 11 2015, 7:49 PM
emaste updated this revision to Diff 3740.

Closed by commit rS278593 (authored by @emaste).