key generates encoded strings of Mapping to be used as a key for maps.
()
| 384 | // key generates encoded strings of Mapping to be used as a key for |
| 385 | // maps. |
| 386 | func (m *Mapping) key() mappingKey { |
| 387 | // Normalize addresses to handle address space randomization. |
| 388 | // Round up to next 4K boundary to avoid minor discrepancies. |
| 389 | const mapsizeRounding = 0x1000 |
| 390 | |
| 391 | size := m.Limit - m.Start |
| 392 | size = size + mapsizeRounding - 1 |
| 393 | size = size - (size % mapsizeRounding) |
| 394 | key := mappingKey{ |
| 395 | size: size, |
| 396 | offset: m.Offset, |
| 397 | } |
| 398 | |
| 399 | switch { |
| 400 | case m.BuildID != "": |
| 401 | key.buildIDOrFile = m.BuildID |
| 402 | case m.File != "": |
| 403 | key.buildIDOrFile = m.File |
| 404 | default: |
| 405 | // A mapping containing neither build ID nor file name is a fake mapping. A |
| 406 | // key with empty buildIDOrFile is used for fake mappings so that they are |
| 407 | // treated as the same mapping during merging. |
| 408 | } |
| 409 | return key |
| 410 | } |
| 411 | |
| 412 | type mappingKey struct { |
| 413 | size, offset uint64 |
no outgoing calls
no test coverage detected