[PATCH] D79013: [llvm-readelf] - Do not crash when the PT_INTERP has an invalid offset.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 03:20:31 PDT 2020
grimar requested review of this revision.
grimar 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]
----------------
jhenderson wrote:
> 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.
Just in case to confirm that my understanding about "leading zeroes" was correct here,
here is a result of my experiments:
The following works:
```
# ERROR-INTERP: Type Offset
# ERROR-INTERP-NEXT: INTERP 0x000[[#%x,OFFSET:0x230]]
```
```
# ERROR-INTERP: Type Offset
# ERROR-INTERP-NEXT: INTERP 0x000[[#%x,OFFSET:0x000230]]
```
The following doesn't:
```
# ERROR-INTERP: Type Offset
# ERROR-INTERP-NEXT: INTERP 0x[[#%x,OFFSET:0x230]]
```
```
# ERROR-INTERP: Type Offset
# ERROR-INTERP-NEXT: INTERP 0x[[#%x,OFFSET:230]]
```
So we need the "0x000[[" part, but do not need leading zeroes for `OFFSET`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79013/new/
https://reviews.llvm.org/D79013
More information about the llvm-commits
mailing list