Unverified Commit 17022fdb by Melvin Klimke Committed by GitHub

Fix pointer to external function (#101)

parent a3a73e8d
......@@ -15,6 +15,7 @@ fn mock_extern_symbol(name: &str) -> ExternSymbol {
let arg = Arg::Register(register("RDX"));
ExternSymbol {
tid: Tid::new("extern_".to_string() + name),
addresses: vec![],
name: name.into(),
calling_convention: None,
parameters: vec![arg.clone()],
......
......@@ -276,6 +276,7 @@ fn clear_parameters_on_the_stack_on_extern_calls() {
};
let extern_symbol = ExternSymbol {
tid: Tid::new("symbol"),
addresses: vec![],
name: "my_extern_symbol".into(),
calling_convention: None,
parameters: vec![stack_param],
......
......@@ -217,6 +217,8 @@ pub enum Arg {
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]
pub struct ExternSymbol {
pub tid: Tid,
/// Addresses of possibly multiple locations of the same extern symbol
pub addresses: Vec<String>,
/// The name of the extern symbol
pub name: String,
/// The calling convention used for the extern symbol if known
......
......@@ -294,7 +294,7 @@ impl From<Sub> for IrSub {
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]
pub struct ExternSymbol {
pub tid: Tid,
pub address: String,
pub addresses: Vec<String>,
pub name: String,
pub calling_convention: Option<String>,
pub arguments: Vec<Arg>,
......@@ -337,6 +337,7 @@ impl From<ExternSymbol> for IrExternSymbol {
}
IrExternSymbol {
tid: symbol.tid,
addresses: symbol.addresses,
name: symbol.name,
calling_convention: symbol.calling_convention,
parameters,
......@@ -655,7 +656,9 @@ mod tests {
"id": "sub_08048410",
"address": "08048410"
},
"address": "08048410",
"addresses": [
"08048410"
],
"name": "atoi",
"calling_convention": "__cdecl",
"arguments": [
......
......@@ -76,6 +76,7 @@ impl From<ExternSymbol> for IrExternSymbol {
}
IrExternSymbol {
tid: symbol.tid,
addresses: vec![symbol.address],
name: symbol.name,
calling_convention: None, // We do not parse more than one calling convention from BAP at the moment. So we assume everything uses the standard one.
parameters,
......
......@@ -11,8 +11,8 @@ public class ExternSymbol {
@SerializedName("tid")
private Tid tid;
@SerializedName("address")
private String address;
@SerializedName("addresses")
private ArrayList<String> addresses;
@SerializedName("name")
private String name;
@SerializedName("calling_convention")
......@@ -23,11 +23,12 @@ public class ExternSymbol {
private Boolean noReturn;
public ExternSymbol() {
this.setAddresses(new ArrayList<String>());
}
public ExternSymbol(Tid tid, String address, String name, String callingConvention, ArrayList<Arg> arguments, Boolean noReturn) {
public ExternSymbol(Tid tid, ArrayList<String> addresses, String name, String callingConvention, ArrayList<Arg> arguments, Boolean noReturn) {
this.setTid(tid);
this.setAddress(address);
this.setAddresses(addresses);
this.setName(name);
this.setCallingConvention(callingConvention);
this.setArguments(arguments);
......@@ -42,12 +43,12 @@ public class ExternSymbol {
this.tid = tid;
}
public String getAddress() {
return address;
public ArrayList<String> getAddresses() {
return addresses;
}
public void setAddress(String address) {
this.address = address;
public void setAddresses(ArrayList<String> addresses) {
this.addresses = addresses;
}
public String getName() {
......
......@@ -22,9 +22,8 @@ public class Program {
this.setSubs(subs);
}
public Program(ArrayList<Term<Sub>> subs, ArrayList<ExternSymbol> externSymbols, ArrayList<Tid> entryPoints) {
public Program(ArrayList<Term<Sub>> subs, ArrayList<Tid> entryPoints) {
this.setSubs(subs);
this.setExternSymbols(externSymbols);
this.setEntryPoints(entryPoints);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment