• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1describe('elf reader', function()
2
3	local ok, elf = pcall(require, 'bpf.elf')
4	if not ok then return end
5
6	it('should handle C library', function()
7		-- Open libc
8		local sh = elf.open('/bin/sh')
9		assert.truthy(sh)
10		-- Find load address
11		local base = sh:loadaddr()
12		assert.truthy(base)
13		-- Find something from ISO C
14		local malloc_addr = sh:resolve('malloc')
15		assert.truthy(malloc_addr)
16		-- Find something that doesn't exist
17		local bad_addr = sh:resolve('thisnotexists')
18		assert.falsy(bad_addr)
19	end)
20	it('should fail on bad input', function()
21		assert.falsy(elf.open(nil))
22		assert.falsy(elf.open('/tmp'):loadaddr())
23	end)
24end)
25