Page MenuHomeFreeBSD

dtrace: fix symbol address resolving
ClosedPublic

Authored by zldrobit_gmail.com on Mon, Jul 7, 7:34 AM.
Tags
Referenced Files
Unknown Object (File)
Tue, Jul 22, 7:50 AM
Unknown Object (File)
Sun, Jul 20, 9:18 PM
Unknown Object (File)
Wed, Jul 16, 7:26 AM
Unknown Object (File)
Fri, Jul 11, 9:02 PM
Unknown Object (File)
Fri, Jul 11, 9:02 PM
Unknown Object (File)
Fri, Jul 11, 9:02 PM
Unknown Object (File)
Fri, Jul 11, 9:02 PM
Unknown Object (File)
Fri, Jul 11, 9:02 PM

Details

Summary

Dtrace assumes only ELF sections of type SHT_PROGBITS or SHT_NOBITS occupy memory space. However, sections with SHF_ALLOC flag also consume memory space. Moreover, the symbol address initialization skips symbols at the very beginning of a section.

Fix: Check section flag for calculating section offset, and disable the skipping at the beginning of a section.

PR: 288000

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

@zldrobit_gmail.com if you cannot submit the change for review from Git (e.g., using git-arc), can you update it with a diff created with -U999 option?

This change looks reasonable to me. I think the problem with st_value = 0 only applies to ET_REL KLDs.

cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
162

Shouldn't we make the same change in dt_module_sysinit32()?

The patch is updated:

  1. Delete sym->st_value != 0 in dt_module_syminit32().
  2. Generate patch file with -U999 option.

@avg Sure, I recreated the patch with the -U999 option.

cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
162

Thanks for your suggestion. I updated the patch accordingly. Plz check the new version.

I'll commit this once I've gone through the test suite.

This revision is now accepted and ready to land.Mon, Jul 7, 4:56 PM
zldrobit_gmail.com marked an inline comment as not done.

@markj I found that we should also delete st_value = 0 in dt_module_symsort32/64(), otherwise dmp->dm_aslen would always be lesser than dmp->dm_asrsv by at least one. As a result, dt_module_symsort32/64() ignore the last element in dmp->dm_asmap and dt_module_symaddr32/64() wouldn't find it. I had to update the patch accordingly. Sorry for interrupting the test suite procedure.

This revision now requires review to proceed.Mon, Jul 7, 6:20 PM

@markj I found that we should also delete st_value = 0 in dt_module_symsort32/64(), otherwise dmp->dm_aslen would always be lesser than dmp->dm_asrsv by at least one. As a result, dt_module_symsort32/64() ignore the last element in dmp->dm_asmap and dt_module_symaddr32/64() wouldn't find it. I had to update the patch accordingly. Sorry for interrupting the test suite procedure.

Good catch, thank you.

@markj I found that we should also delete st_value = 0 in dt_module_symsort32/64(), otherwise dmp->dm_aslen would always be lesser than dmp->dm_asrsv by at least one. As a result, dt_module_symsort32/64() ignore the last element in dmp->dm_asmap and dt_module_symaddr32/64() wouldn't find it. I had to update the patch accordingly. Sorry for interrupting the test suite procedure.

It would be nice to refactor this ST_BIND != STB_LOCAL || sym->st_size != 0 check into a helper function, but this should be done in a separate patch.

This revision was not accepted when it landed; it landed in state Needs Review.Mon, Jul 7, 8:17 PM
This revision was automatically updated to reflect the committed changes.