Project

General

Profile

Bug #18081 ยป ruby-addr2line-section-for-DW_AT_ranges.patch

addr2line.c: Correct section for `DW_AT_ranges` - xtkoba (Tee KOBAYASHI), 08/17/2021 02:02 PM

View differences:

addr2line.c
844 844
    const char *pend;
845 845
    const char *q0;
846 846
    const char *q;
847
    uint16_t version;
847 848
    int format; // 4 or 8
848 849
    uint8_t address_size;
849 850
    uint64_t debug_abbrev_offset;
......
1446 1447
        const char *p;
1447 1448
        uint64_t base = ptr->low_pc_set ? ptr->low_pc : reader->current_low_pc;
1448 1449
        bool base_valid = true;
1449
        if (reader->obj->debug_rnglists.ptr) {
1450
        if (reader->version >= 5) {
1451
            if (!reader->obj->debug_rnglists.ptr) {
1452
                return false;
1453
            }
1450 1454
            p = reader->obj->debug_rnglists.ptr + ptr->ranges;
1451 1455
            for (;;) {
1452 1456
                uint8_t rle = read_uint8(&p);
......
1489 1493
            }
1490 1494
            return false;
1491 1495
        }
1496
        /* assert(reader->version < 5); */
1497
        if (!reader->obj->debug_ranges.ptr) {
1498
            return false;
1499
        }
1492 1500
        p = reader->obj->debug_ranges.ptr + ptr->ranges;
1493 1501
        for (;;) {
1494 1502
            uintptr_t from = read_uintptr(&p);
......
1546 1554
di_read_cu(DebugInfoReader *reader)
1547 1555
{
1548 1556
    uint64_t unit_length;
1549
    uint16_t version;
1550 1557
    reader->format = 4;
1551 1558
    reader->current_cu = reader->p;
1552 1559
    unit_length = read_uint32(&reader->p);
......
1555 1562
        reader->format = 8;
1556 1563
    }
1557 1564
    reader->cu_end = reader->p + unit_length;
1558
    version = read_uint16(&reader->p);
1559
    if (version > 5) {
1565
    reader->version = read_uint16(&reader->p);
1566
    if (reader->version > 5) {
1560 1567
        return -1;
1561 1568
    }
1562
    else if (version == 5) {
1569
    else if (reader->version == 5) {
1563 1570
        /* unit_type = */ read_uint8(&reader->p);
1564 1571
        reader->address_size = read_uint8(&reader->p);
1565 1572
        reader->debug_abbrev_offset = read_uint(reader);