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

Add simple C test and fix gnu_hash verifier #56

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions linker-diff/src/gnu_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ pub(crate) fn check_object(obj: &Object) -> Result {
dynamic symbols ({num_symbols})"
)
})?;

// For a simple binary, both LLD and BFD create .gnu.hash section that does not contain any chain:
// Contents of section .gnu.hash:
// objdump -s -j .gnu.hash
// 4003e8 01000000 01000000 01000000 00000000
// 4003f8 00000000 00000000 00000000
if buckets == [0] && rest.is_empty() {
return Ok(());
}

let (chains, _) = object::slice_from_bytes::<u32>(rest, chain_count).map_err(|_| {
anyhow!(
"Insufficient data for .gnu.hash chains. \
Expand Down
1 change: 1 addition & 0 deletions wild/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ fn setup_symlink() {
fn integration_test(
#[values(
"trivial.c",
"trivial-main.c",
"link_args.c",
"global_definitions.c",
"data.c",
Expand Down
10 changes: 10 additions & 0 deletions wild/tests/sources/trivial-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//#AbstractConfig:default
//#LinkArgs:--cc=gcc -Wl,-z,now
//#DiffIgnore:.dynamic.DT_NEEDED
//#DiffIgnore:section.rodata
//#DiffIgnore:section.data

int main()
{
return 42;
}