faerie
faerie copied to clipboard
zero-initialized data symbols have incorrect symbol sizes
STR:
let name = "test.o";
let file = File::create(Path::new(name)).unwrap();
let mut obj = ArtifactBuilder::new(Triple {
architecture: Architecture::X86_64,
vendor: Vendor::Unknown,
operating_system: OperatingSystem::Unknown,
environment: Environment::Unknown,
binary_format: BinaryFormat::Elf,
})
.name(name.to_owned())
.finish();
obj.declare("zeroinit", Decl::data()).unwrap();
obj.define_zero_init("zeroinit", 8).unwrap();
obj.write(file).unwrap();
$ readelf -sW test.o
Symbol table '.symtab' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test.o
2: 0000000000000000 0 SECTION LOCAL DEFAULT 3
3: 0000000000000000 0 OBJECT LOCAL DEFAULT 3 zeroinit
zeroinit
should have a size of 8, not a size of 0.
@jyn514 worked on this, maybe they can help?
My first question is the size the physical disk size or memory size? Physical disk size should be 0; if memory size isn't 8 then yes, it appears to be wrong.
This might be https://github.com/m4b/faerie/pull/99#issuecomment-534143293 ? Not sure, I haven't looked at this since my PR.
My first question is the size the physical disk size or memory size? Physical disk size should be 0; if memory size isn't 8 then yes, it appears to be wrong.
Symbols only ever have the memory size. The bug appears to be that the file size is being used. https://github.com/m4b/faerie/blob/8d0d03a7688b7f757c4357183eb8eec90a67255d/src/elf.rs#L501 https://github.com/m4b/faerie/blob/8d0d03a7688b7f757c4357183eb8eec90a67255d/src/elf.rs#L559