mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-5189 Add range attributes to VarargsFilter
This commit is contained in:
parent
57df41297f
commit
e3aa064061
10 changed files with 128 additions and 28 deletions
|
@ -3433,6 +3433,10 @@ void ProtoStoreInternal::decode(Decoder &decoder,ProtoModel *model)
|
|||
addressesdetermined = false;
|
||||
|
||||
uint4 elemId = decoder.openElement(ELEM_INTERNALLIST);
|
||||
uint4 firstId = decoder.getNextAttributeId();
|
||||
if (firstId == ATTRIB_FIRST) {
|
||||
proto.firstVarArgSlot = decoder.readSignedInteger();
|
||||
}
|
||||
for(;;) { // This is only the input params
|
||||
uint4 subId = decoder.openElement(); // <retparam> or <param>
|
||||
if (subId == 0) break;
|
||||
|
|
|
@ -412,13 +412,22 @@ bool VarargsFilter::filter(const PrototypePieces &proto,int4 pos) const
|
|||
|
||||
{
|
||||
if (proto.firstVarArgSlot < 0) return false;
|
||||
return (pos >= proto.firstVarArgSlot);
|
||||
pos -= proto.firstVarArgSlot;
|
||||
return (pos >= firstPos && pos <= lastPos);
|
||||
}
|
||||
|
||||
void VarargsFilter::decode(Decoder &decoder)
|
||||
|
||||
{
|
||||
uint4 elemId = decoder.openElement(ELEM_VARARGS);
|
||||
for(;;) {
|
||||
uint4 attribId = decoder.getNextAttributeId();
|
||||
if (attribId == 0) break;
|
||||
if (attribId == ATTRIB_FIRST)
|
||||
firstPos = decoder.readSignedInteger();
|
||||
else if (attribId == ATTRIB_LAST)
|
||||
lastPos = decoder.readSignedInteger();
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -190,15 +190,24 @@ public:
|
|||
virtual void decode(Decoder &decoder) {}
|
||||
};
|
||||
|
||||
/// \brief A filter that selects function parameters that are considered optional
|
||||
/// \brief A filter that selects a range of function parameters that are considered optional.
|
||||
///
|
||||
/// If the underlying function prototype is considered to take variable arguments, the first
|
||||
/// \e n parameters (as determined by PrototypePieces.firstVarArgSlot) are considered non-optional.
|
||||
/// If additional data-types are provided beyond the initial \e n, these are considered optional.
|
||||
/// This filter returns \b true for these optional parameters
|
||||
/// n parameters (as determined by PrototypePieces.firstVarArgSlot) are considered non-optional.
|
||||
///\e If additional data-types are provided beyond the initial \e n, these are considered optional.
|
||||
/// By default this filter matches on any parameter in a prototype with variable arguments.
|
||||
/// Optionally, it can filter on a range of parameters that are specified relative to the
|
||||
/// first variable argument.
|
||||
/// - \<varargs first="0"/> - matches optional arguments but not non-optional ones.
|
||||
/// - \<varargs first="0" last="0"/> - matches the first optional argument.
|
||||
/// - \<varargs first="-1"/> - matches the last non-optional argument and all optional ones.
|
||||
class VarargsFilter : public QualifierFilter {
|
||||
int4 firstPos; ///< Start of range to match (offset relative to first variable arg)
|
||||
int4 lastPos; ///< End of range to match
|
||||
public:
|
||||
virtual QualifierFilter *clone(void) const { return new VarargsFilter(); }
|
||||
VarargsFilter(void) { firstPos = 0x80000000; lastPos = 0x7fffffff; }
|
||||
VarargsFilter(int4 first,int4 last) { firstPos = first; lastPos = last; }
|
||||
virtual QualifierFilter *clone(void) const { return new VarargsFilter(firstPos,lastPos); }
|
||||
virtual bool filter(const PrototypePieces &proto,int4 pos) const;
|
||||
virtual void decode(Decoder &decoder);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue