Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zero-initialized data symbols have incorrect symbol sizes #111

Open
froydnj opened this issue Mar 11, 2020 · 3 comments
Open

zero-initialized data symbols have incorrect symbol sizes #111

froydnj opened this issue Mar 11, 2020 · 3 comments

Comments

@froydnj
Copy link

froydnj commented Mar 11, 2020

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
Copy link
Owner

m4b commented Mar 12, 2020

@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.

@jyn514
Copy link
Contributor

jyn514 commented Mar 12, 2020

This might be #99 (comment) ? Not sure, I haven't looked at this since my PR.

@philipc
Copy link
Collaborator

philipc commented Mar 12, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants