This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Solve the misalignment problem caused by RISCV_ATTRIBUTES
AbandonedPublic

Authored by achieveartificialintelligence on Dec 28 2021, 10:14 PM.

Details

Summary

RISCV_ATTRIBUTES causes the number of columns in Type to be insufficient

before

There are 12 section headers, starting at offset 0x4e0:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .strtab           STRTAB          0000000000000000 0003fc 0000dd 00      0   0  1
  [ 2] .text             PROGBITS        0000000000000000 000040 000070 00  AX  0   0  4
  [ 3] .rela.text        RELA            0000000000000000 000260 000198 18   I 11   2  8
  [ 4] .sdata            PROGBITS        0000000000000000 0000b0 000008 00  WA  0   0  4
  [ 5] .rodata.str1.1    PROGBITS        0000000000000000 0000b8 000004 01 AMS  0   0  1
  [ 6] .sbss             NOBITS          0000000000000000 0000bc 000008 00  WA  0   0  4
  [ 7] .comment          PROGBITS        0000000000000000 0000bc 00006a 01  MS  0   0  1
  [ 8] .note.GNU-stack   PROGBITS        0000000000000000 000126 000000 00      0   0  1
  [ 9] .riscv.attributes RISCV_ATTRIBUTES 0000000000000000 000126 000047 00      0   0  1
  [10] .llvm_addrsig     LLVM_ADDRSIG    0000000000000000 0003f8 000004 00   E 11   0  1
  [11] .symtab           SYMTAB          0000000000000000 000170 0000f0 18      1   5  8

after

There are 12 section headers, starting at offset 0x4e0:

Section Headers:
  [Nr] Name              Type             Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL             0000000000000000 000000 000000 00      0   0  0
  [ 1] .strtab           STRTAB           0000000000000000 0003fc 0000dd 00      0   0  1
  [ 2] .text             PROGBITS         0000000000000000 000040 000070 00  AX  0   0  4
  [ 3] .rela.text        RELA             0000000000000000 000260 000198 18   I 11   2  8
  [ 4] .sdata            PROGBITS         0000000000000000 0000b0 000008 00  WA  0   0  4
  [ 5] .rodata.str1.1    PROGBITS         0000000000000000 0000b8 000004 01 AMS  0   0  1
  [ 6] .sbss             NOBITS           0000000000000000 0000bc 000008 00  WA  0   0  4
  [ 7] .comment          PROGBITS         0000000000000000 0000bc 00006a 01  MS  0   0  1
  [ 8] .note.GNU-stack   PROGBITS         0000000000000000 000126 000000 00      0   0  1
  [ 9] .riscv.attributes RISCV_ATTRIBUTES 0000000000000000 000126 000047 00      0   0  1
  [10] .llvm_addrsig     LLVM_ADDRSIG     0000000000000000 0003f8 000004 00   E 11   0  1
  [11] .symtab           SYMTAB           0000000000000000 000170 0000f0 18      1   5  8

Diff Detail

Event Timeline

achieveartificialintelligence requested review of this revision.Dec 28 2021, 10:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2021, 10:14 PM
jrtc27 added a comment.EditedDec 29 2021, 6:25 AM

llvm-readelf currently almost exactly matches the output of GNU readelf -W, and field widths for -S is one of the ways they currently match. I'm unconvinced this is worthwhile; .note.gnu.build-id already spills over into the Type column for any architecture, so this is not a new problem, and it's not really a problem either.

llvm-readelf currently almost exactly matches the output of GNU readelf -W, and field widths for -S is one of the ways they currently match. I'm unconvinced this is worthwhile; .note.gnu.build-id already spills over into the Type column for any architecture, so this is not a new problem, and it's not really a problem either.

Thanks, I'll close this.