[PATCH] D79013: [llvm-readelf] - Do not crash when the PT_INTERP has an invalid offset.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 02:40:56 PDT 2020


jhenderson added a subscriber: thopre.
jhenderson added inline comments.


================
Comment at: llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test:322
+# ERROR-INTERP:      Type           Offset
+# ERROR-INTERP-NEXT: INTERP         0x000[[#%x,OFFSET:0x000230]]
+# ERROR-INTERP-NEXT:     [Requesting program interpreter: C]
----------------
grimar wrote:
> jhenderson wrote:
> > I believe you don't want the leading 0x000 bit, and then you also won't need the %x either. I believe FileCheck will automatically recognise it as hex that way (as things stand, I think it might not, but can't remember the details). If you want ot be sure that it is hex though, you can keep the %x (and might need it in the lines below too to be sure its always hex, but I'm not sure - experimentation needed). FWIW, I don't think it being hex is a necessary check for this specific case, since we check it earlier.
> > I believe you don't want the leading 0x000 bit, and then you also won't need the %x either.
> 
> It does not work for me, this was the only way I've managed to make this work.
> 
> The following fail:
> 
> 
> ```
> # ERROR-INTERP:      Type           Offset
> # ERROR-INTERP-NEXT: INTERP         [[#OFFSET:]]
> # ERROR-INTERP-NEXT:     [Requesting program interpreter: C]
> # ERROR-INTERP-NEXT: INTERP         [[#OFFSET + 1]]
> # ERROR-INTERP-NEXT:     [Requesting program interpreter: ]
> ```
> 
> ```
> D:\Work3\LLVM\llvm-project\llvm\test\tools\llvm-readobj\ELF\gnu-phdrs.test:324:2
> 2: error: ERROR-INTERP-NEXT: expected string not found in input
> # ERROR-INTERP-NEXT: INTERP [[#OFFSET + 1]]
>                      ^
> <stdin>:10:2: note: scanning from here
>  INTERP 0x000231 0x0000000000000000 0x0000000000000000 0x000000 0x000000 0x1
>  ^
> <stdin>:10:2: note: with "OFFSET + 1" equal to "1"
>  INTERP 0x000231 0x0000000000000000 0x0000000000000000 0x000000 0x000000 0x1
>  ^
> ```
Ah, okay, I guess the 0x is not cosnidered part of the numeric pattern and the default only reads decimal. @thopre, is that correct?

Anyway, from my experiments the leading zeroes can be included, and please specify '%x' explicitly in the definition.


================
Comment at: llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test:327
+# ERROR-INTERP-NEXT: INTERP         0x000[[#OFFSET + 2]]
+# ERROR-INTERP-NEXT: warning: '[[FILE]]': unable to read program interpreter name at offset 0x232: it is not null-terminated
+# ERROR-INTERP-NEXT: INTERP         0x000[[#OFFSET + 3]]
----------------
Don't forget to update `0x232` to `0x[[#OFFSET+2]]` and similar in the messages below.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79013/new/

https://reviews.llvm.org/D79013





More information about the llvm-commits mailing list