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 { ...@@ -15,6 +15,7 @@ fn mock_extern_symbol(name: &str) -> ExternSymbol {
let arg = Arg::Register(register("RDX")); let arg = Arg::Register(register("RDX"));
ExternSymbol { ExternSymbol {
tid: Tid::new("extern_".to_string() + name), tid: Tid::new("extern_".to_string() + name),
addresses: vec![],
name: name.into(), name: name.into(),
calling_convention: None, calling_convention: None,
parameters: vec![arg.clone()], parameters: vec![arg.clone()],
......
...@@ -276,6 +276,7 @@ fn clear_parameters_on_the_stack_on_extern_calls() { ...@@ -276,6 +276,7 @@ fn clear_parameters_on_the_stack_on_extern_calls() {
}; };
let extern_symbol = ExternSymbol { let extern_symbol = ExternSymbol {
tid: Tid::new("symbol"), tid: Tid::new("symbol"),
addresses: vec![],
name: "my_extern_symbol".into(), name: "my_extern_symbol".into(),
calling_convention: None, calling_convention: None,
parameters: vec![stack_param], parameters: vec![stack_param],
......
...@@ -217,6 +217,8 @@ pub enum Arg { ...@@ -217,6 +217,8 @@ pub enum Arg {
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]
pub struct ExternSymbol { pub struct ExternSymbol {
pub tid: Tid, pub tid: Tid,
/// Addresses of possibly multiple locations of the same extern symbol
pub addresses: Vec<String>,
/// The name of the extern symbol /// The name of the extern symbol
pub name: String, pub name: String,
/// The calling convention used for the extern symbol if known /// The calling convention used for the extern symbol if known
......
...@@ -294,7 +294,7 @@ impl From<Sub> for IrSub { ...@@ -294,7 +294,7 @@ impl From<Sub> for IrSub {
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]
pub struct ExternSymbol { pub struct ExternSymbol {
pub tid: Tid, pub tid: Tid,
pub address: String, pub addresses: Vec<String>,
pub name: String, pub name: String,
pub calling_convention: Option<String>, pub calling_convention: Option<String>,
pub arguments: Vec<Arg>, pub arguments: Vec<Arg>,
...@@ -337,6 +337,7 @@ impl From<ExternSymbol> for IrExternSymbol { ...@@ -337,6 +337,7 @@ impl From<ExternSymbol> for IrExternSymbol {
} }
IrExternSymbol { IrExternSymbol {
tid: symbol.tid, tid: symbol.tid,
addresses: symbol.addresses,
name: symbol.name, name: symbol.name,
calling_convention: symbol.calling_convention, calling_convention: symbol.calling_convention,
parameters, parameters,
...@@ -655,7 +656,9 @@ mod tests { ...@@ -655,7 +656,9 @@ mod tests {
"id": "sub_08048410", "id": "sub_08048410",
"address": "08048410" "address": "08048410"
}, },
"address": "08048410", "addresses": [
"08048410"
],
"name": "atoi", "name": "atoi",
"calling_convention": "__cdecl", "calling_convention": "__cdecl",
"arguments": [ "arguments": [
......
...@@ -76,6 +76,7 @@ impl From<ExternSymbol> for IrExternSymbol { ...@@ -76,6 +76,7 @@ impl From<ExternSymbol> for IrExternSymbol {
} }
IrExternSymbol { IrExternSymbol {
tid: symbol.tid, tid: symbol.tid,
addresses: vec![symbol.address],
name: symbol.name, 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. 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, parameters,
......
...@@ -11,8 +11,8 @@ public class ExternSymbol { ...@@ -11,8 +11,8 @@ public class ExternSymbol {
@SerializedName("tid") @SerializedName("tid")
private Tid tid; private Tid tid;
@SerializedName("address") @SerializedName("addresses")
private String address; private ArrayList<String> addresses;
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@SerializedName("calling_convention") @SerializedName("calling_convention")
...@@ -23,11 +23,12 @@ public class ExternSymbol { ...@@ -23,11 +23,12 @@ public class ExternSymbol {
private Boolean noReturn; private Boolean noReturn;
public ExternSymbol() { 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.setTid(tid);
this.setAddress(address); this.setAddresses(addresses);
this.setName(name); this.setName(name);
this.setCallingConvention(callingConvention); this.setCallingConvention(callingConvention);
this.setArguments(arguments); this.setArguments(arguments);
...@@ -42,12 +43,12 @@ public class ExternSymbol { ...@@ -42,12 +43,12 @@ public class ExternSymbol {
this.tid = tid; this.tid = tid;
} }
public String getAddress() { public ArrayList<String> getAddresses() {
return address; return addresses;
} }
public void setAddress(String address) { public void setAddresses(ArrayList<String> addresses) {
this.address = address; this.addresses = addresses;
} }
public String getName() { public String getName() {
......
...@@ -22,9 +22,8 @@ public class Program { ...@@ -22,9 +22,8 @@ public class Program {
this.setSubs(subs); 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.setSubs(subs);
this.setExternSymbols(externSymbols);
this.setEntryPoints(entryPoints); 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