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

Ch12: Missing directory #73

Open
yozhgoor opened this issue Feb 15, 2022 · 2 comments
Open

Ch12: Missing directory #73

yozhgoor opened this issue Feb 15, 2022 · 2 comments

Comments

@yozhgoor
Copy link

The ch12/noop from section 12.7 doesn't exists

@ewenmcneill
Copy link

FWIW, apparently ch12/noop was an executable, and it seems to have been added in June 2022:

ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ git log noop
commit 6ebd519f5a691a2f4c7d9cfbdb2d3e708e9d9681 (HEAD -> 1st-edition, origin/HEAD, origin/1st-edition)
Author: Tim McNamara <code@timmcnamara.co.nz>
Date:   Thu Jun 30 22:10:49 2022 +1200

    ch12: add noop binary for completeness
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ 

Possibly that should have resolved this issue?

Ewen

@ewenmcneill
Copy link

Possibly that should have resolved this issue?

Actually in the release version of the book, section 12.7 has two examples referred to as:

rustc ch12/fn-ptr-demo-1.rs && ./fn-ptr-demo-1

and

rustc ch12/fn-ptr-demo-2.rs && ./fn-ptr-demo-2

which are Listing 12.9 and Listing 12.10 respectively. The source to those probably should be in this repository (neither is present, just the noop executable!).

I think the noop binary which was added corresponds to Listing 12.9 (ie fn-ptr-demo-1.rs) based on the output. But it's unclear why the binary was added, rather than the source. Especialy as the binary will, at best, only work on Linux.

Ewen

Listing 12.9 output compared with noop executable output
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ file noop
noop: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bd628d94abc0aaaa7da48da7fe1bca30a3d3fe78, for GNU/Linux 3.2.0, with debug_info, not stripped
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ ldd noop
	linux-vdso.so.1 (0x00007ffd43fe9000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3fab747000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3fab742000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3fab73d000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3fab515000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3fab7b7000)
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ ./noop 
noop as usize: 0x5578c49d7780
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ cat fn-ptr-demo-1.rs 
fn noop() {}

fn main() {
    let fn_ptr = noop as usize;
    println!("noop as usize: 0x{:x}", fn_ptr);
}
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ rustc fn-ptr-demo-1.rs 
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ ./fn-ptr-demo-1 
noop as usize: 0x55f529136400
ewen@rustdev:~/misc/src/rust/rust-in-action/ch12$ 


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

2 participants