m4b/faerie

zero-initialized data symbols have incorrect symbol sizes

froydnj opened this issue · 3 comments

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.

m4b commented

@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 #99 (comment) ? 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.

let def_size = def.data.file_size();

.size(def_size)