Skip to content

Commit

Permalink
Fix incorrect inequality and add tests (#15)
Browse files Browse the repository at this point in the history
Fix incorrect inequality and add tests
  • Loading branch information
staticfloat authored Oct 9, 2019
2 parents 6a66694 + 6f8ebd4 commit abc06f9
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ os:
- osx
julia:
- 1.0
- 1.3
- nightly
notifications:
email: false
Expand Down
74 changes: 74 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This file is machine-generated - editing it directly is not advised

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[LibGit2]]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Reexport]]
deps = ["Pkg"]
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "0.2.0"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[StructIO]]
deps = ["Test"]
git-tree-sha1 = "010dc73c7146869c042b49adcdb6bf528c12e859"
uuid = "53d494c1-5632-5724-8f4c-31dff12d585f"
version = "0.3.0"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
13 changes: 13 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = "ObjectFile"
uuid = "d8793406-e978-5875-9003-1fc021f44a92"
authors = ["Elliot Saba <[email protected]>"]
version = "0.3.3"

[deps]
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
StructIO = "53d494c1-5632-5724-8f4c-31dff12d585f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
StructIO = "≥ 0.3"
julia = "≥ 1"
4 changes: 2 additions & 2 deletions src/COFF/COFFDynamicLink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ end

function find_section_for_rva(oh::H, rva) where {H <: COFFHandle}
for s in Sections(oh)
if section_address(s) < rva && section_address(s) + section_size(s) > rva
if section_address(s) <= rva && section_address(s) + section_size(s) > rva
return s
end
end
error("Unable to find section for RVA $(rva)")
error("Unable to find section for RVA $(repr(rva))")
end

function COFFDynamicLinks(oh::H) where {H <: COFFHandle}
Expand Down
27 changes: 26 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,29 @@ test_libfoo_and_fooifier("./win64/fooifier.exe", "./win64/libfoo.dll")
version_symbols = filter(x -> startswith(x, "GLIBCXX_"), version_symbols)
max_version = maximum([VersionNumber(split(v, "_")[2]) for v in version_symbols])
@test max_version == v"3.4.25"
end
end


# Ensure that these tricksy win32 files work
@testset "git win32 problems" begin
# Test that 6a66694a8dd5ca85bd96fe6236f21d5b183e7de6 fix worked
libmsobj_path = "./win32/msobj140.dll"

dynamic_links = readmeta(libmsobj_path) do oh
path.(DynamicLinks(oh))
end

@test "KERNEL32.dll" in dynamic_links
@test "api-ms-win-crt-heap-l1-1-0.dll" in dynamic_links
@test "api-ms-win-crt-convert-l1-1-0.dll" in dynamic_links
@test "api-ms-win-crt-runtime-l1-1-0.dll" in dynamic_links

whouses_exe = "./win32/WhoUses.exe"
dynamic_links = readmeta(whouses_exe) do oh
path.(DynamicLinks(oh))
end

@test "ADVAPI32.dll" in dynamic_links
@test "KERNEL32.dll" in dynamic_links
@test "libstdc++-6.dll" in dynamic_links
end
Binary file added test/win32/WhoUses.exe
Binary file not shown.
Binary file added test/win32/msobj140.dll
Binary file not shown.

0 comments on commit abc06f9

Please sign in to comment.