Skip to content

Remove cross OS DAC dependence on TARGET_ALPINE_LINUX #32756

Closed

Description

@sdmaclea

Background

As part of #32322 @jkotas suggested that the Linux and Alpine Cross OS DACs do not necessarily need to be different. It would be nice to just build one of them.

However in fixing the alpine build breaks introduced by the original elf-reader implementation #32579
introduced a dependence on TARGET_ALPINE_LINUX in the elf-reader.

It would be nice to eliminate this dependence. I suspect it should be feasible.

The root cause for the dependence is a difference in how the loader populates the symbol tables. For most unix variants the symbol table is fixed up to contain absolute addresses rather than the relative addresses as stored on disk.

Possible ideas:

  • My initial idea was to simply probe both addresses and look for a well known token. This is a bit costly as it could lead to segment faults when we probe an unmapped address.

  • The next idea is simpler. If the symbol lookup results in a symbol with address less than the module base address then add the base address. This would work for most realistic cases. It would fail if the module was loaded at an address smaller than its size. This is a bit fragile....

  • If we combine the two ideas, it seems we can fully cover the bases.

Discussion topics:

Should we try to only build one Cross OS DAC for Linux & Alpine?

Is the combined approach robust enough?

Is there a better way?

/cc @jkotas @noahfalk @mikem8361 @dotnet/dotnet-diag

Activity

  1. added this to the 5.0 milestone on Feb 24, 2020
  2. added
    untriaged
    on Feb 24, 2020
  3. jkotas commented on Feb 24, 2020

    @jkotas
    Member

    how the loader populates the symbol tables

    I would expect the ELF format to have enum somewhere that describes the type of table. Is there one that we can get to?

  4. mikem8361 commented on Feb 28, 2020

    @mikem8361
    Contributor

    I looked all over the web and didn't find anything, but there wasn't much on the in-memory layout/format. It was all about the file format itself. None of the other distros we test on (ubuntu, fedora, debian, opensuse) have this problem. I think alpine's loader just doesn't fix up these RVAs.

  5. removed
    untriaged
    on Mar 7, 2020
  6. sdmaclea commented on Mar 12, 2020

    @sdmaclea
    ContributorAuthor

    We discussed this briefly a few days ago in our stand up meeting. The consensus was we can

    • Use the heuristic RVA < Base address will cover most cases
    • We can add a cookie to the g_DacTable to determine if the heuristic failed (and auto correct).
    • During dump debugging examining unmapped memory will not lead to a segmentation fault. So we can easily look at this during dump analysis.
    • createdump has more flexibility. For it a dependence on TARGET_ALPINE_LINUX is acceptable.
  7. self-assigned this
    on Mar 31, 2020
  8. sdmaclea commented on May 16, 2020

    @sdmaclea
    ContributorAuthor

    We discussed the #34314 PR which fixed this issue. At the moment the added complexity was not worth it.

    Closing the issue as will not fix

  9. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions