Code Monkey home page Code Monkey logo

smol's People

Contributors

blackle avatar porocyon avatar shizmob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

smol's Issues

Add LTO compatibility

Currently using readelf to find symbols, which can't properly parse LTO objects. Use something that does instead? (nm?)

Is this even possible? Relocation types need to be known by smolemit.py...

TODO: warn when no _start function is found, or is at the wrong place

Users not doing this correctly will be faced by cryptic segfaults.

A warning (or error) should be shown if the following is not true:

  • There is exactly one .text.startup._start or .text._start section (can't have both, can't have none)
  • The _start symbol must be at the very beginning of the above section.

Incorrect function address calc (maybe?)

I hit a segfault issue trying to change up my build process a bit.

Long story short, I've narrowed the problem down to the first function call to anything linked from outside the main obj file. In this case, moving my function from the same file as main() to a different .o introduces a segfault on the call instruction and the calculated address looks wrong to me, but that's where my knowledge runs dry. it seems like the address of all the call instructions are off by a few bytes but I could be misreading or misinterpreting GDB output.

Relevant, my debugging symbols are borked per #14 and the stack trace is frankly dizzying without them.

If you give me a hint I can probably figure out the fix and PR it, I've been using this thing a bit and I want to better understand it, would enjoy contributing.

The scanelf-removal commit (405d8eb, #9) borks

python3 ./smold.py --debugout "bin/hello-crt.dbg" --smolrt "./rt" --smolld "./ld" -falign-stack -fuse-interp -fifunc-support --verbose  --ldflags=-Wl,-Map=bin/hello-crt.map -lSDL2 -lX11 -lm -lc  "obj/hello.lto.o" obj/crt1.lto.o "bin/hello-crt"
arch: x86_64
cc: ['/usr/bin/cc', '-m64', '-nostartfiles', '-nostdlib', '-r', '-flinker-output=nolto-rel', '-o', '/tmp/smolinch82g1jp.o', 'obj/hello.lto.o', 'obj/crt1.lto.o']
libs = ['/usr/lib/libSDL2.so', '/usr/lib/libX11.so.6', '/usr/lib/libm.so.6', '/usr/lib/libc.so.6']
  File "./smold.py", line 216, in <module>
    rv = main()
  File "./smold.py", line 188, in main
    error("E: the symbol '" + symbol + "' is provided by more than one library: " + str(libs_for_symbol))
  File "./smol/shared.py", line 70, in error
    traceback.print_stack()
E: the symbol 'printf' is provided by more than one library: ['libc.so.6', 'libc.so.6']

See 4601003 , cf. #4 and #9

EDIT: this is present in 405d8eb as well, rolling back master for now

--debugout fails linking step

Recently ran into a problem with segfaults (separate issue incoming... 😁 ) and discovered that the --debugout flag causes my ld to break and complain about a discarded .got.plt section. Worth noting these .o files are products of Rust. I managed to get it to link by removing the catch-all DISCARD in the linker script but then none of the debug symbols lined up.

I can provide objdumps or whatever of the two .o files and the /tmp/ stuff, just let me know what you'd want

make python error

make all fails on ubuntu 18.04

cc -flto -Wall -Wextra -Wpedantic -std=gnu11 -nostartfiles -fno-PIC -Os -fno-plt -fno-stack-protector -fno-stack-check -fno-unwind-tables -fno-asynchronous-unwind-tables -fomit-frame-pointer -ffast-math -no-pie -fno-pic -fno-PIE -m64 -march=core2 -ffunction-sections -fdata-sections -fno-plt -m64 -D_REENTRANT -I/usr/include/SDL2 -c "test/hello.c" -o "obj/hello.lto.o"
cc -flto -Wall -Wextra -Wpedantic -std=gnu11 -nostartfiles -fno-PIC -Os -fno-plt -fno-stack-protector -fno-stack-check -fno-unwind-tables -fno-asynchronous-unwind-tables -fomit-frame-pointer -ffast-math -no-pie -fno-pic -fno-PIE -m64 -march=core2 -ffunction-sections -fdata-sections -fno-plt -m64 -D_REENTRANT -I/usr/include/SDL2 -c "rt/crt1.c" -o "obj/crt1.lto.o"
rt/crt1.c:22:1: warning: 'naked' attribute directive ignored [-Wattributes]
) {
^
cc -m64 -nostartfiles -nostdlib -r -o "obj/hello.start.o" obj/hello.lto.o obj/crt1.lto.o
python3 src/smol.py -lc -lSDL2 -lX11 "obj/hello.start.o" "obj/symbols.hello.start.asm"
Traceback (most recent call last):
File "src/smol.py", line 77, in
main()
File "src/smol.py", line 67, in main
library = find_symbol(args.scanelf, libs, libnames, symbol)
File "/home/martin/work/demos/Clutter-1k/smol/src/smolparse.py", line 127, in find_symbol
'+{}'.format(symbol)] + libraries, stderr=subprocess.DEVNULL)
File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.6/subprocess.py", line 729, in init
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1278, in _execute_child
executable = os.fsencode(executable)
File "/usr/lib/python3.6/os.py", line 800, in fsencode
filename = fspath(filename) # Does type-checking of filename.
TypeError: expected str, bytes or os.PathLike object, not NoneType
Makefile:83: recipe for target 'obj/symbols.hello.start.asm' failed
make: *** [obj/symbols.hello.start.asm] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.