diff options
| author | grischka <grischka> | 2016-12-15 17:01:22 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2016-12-15 17:01:22 +0100 |
| commit | ca92bfc3c64128872793c167de3a58a78b9a1299 (patch) | |
| tree | d8fe09de7934dc0c23aef2417ce2bb9d589512f3 /tests | |
| parent | fe6453f8f08b5c21a339b3169a837772a9864d62 (diff) | |
| download | tinycc-ca92bfc3c64128872793c167de3a58a78b9a1299.tar.gz tinycc-ca92bfc3c64128872793c167de3a58a78b9a1299.tar.bz2 | |
tccelf: some linker cleanup
- generate and use SYM@PLT for plt addresses
- get rid of patch_dynsym_undef hack (no idea what it did on FreeBSD)
- use sym_attrs instead of symtab_to_dynsym
- special case for function pointers into .so on i386
- libtcc_test: test tcc_add_symbol with data object
- move target specicic code to *-link.c files
- add R_XXX_RELATIVE (needed for PE)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/libtcc_test.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/libtcc_test.c b/tests/libtcc_test.c index 109e488..be5db61 100644 --- a/tests/libtcc_test.c +++ b/tests/libtcc_test.c @@ -15,9 +15,12 @@ int add(int a, int b) return a + b; } +const char hello[] = "Hello World!"; + char my_program[] = "#include <tcclib.h>\n" /* include the "Simple libc header for TCC" */ "extern int add(int a, int b);\n" +"extern const char hello[];\n" "int fib(int n)\n" "{\n" " if (n <= 2)\n" @@ -28,7 +31,7 @@ char my_program[] = "\n" "int foo(int n)\n" "{\n" -" printf(\"Hello World!\\n\");\n" +" printf(\"%s\\n\", hello);\n" " printf(\"fib(%d) = %d\\n\", n, fib(n));\n" " printf(\"add(%d, %d) = %d\\n\", n, 2 * n, add(n, 2 * n));\n" " return 0;\n" @@ -65,9 +68,10 @@ int main(int argc, char **argv) if (tcc_compile_string(s, my_program) == -1) return 1; - /* as a test, we add a symbol that the compiled program can use. + /* as a test, we add symbols that the compiled program can use. You may also open a dll with tcc_add_dll() and use symbols from that */ tcc_add_symbol(s, "add", add); + tcc_add_symbol(s, "hello", hello); /* relocate the code */ if (tcc_relocate(s, TCC_RELOCATE_AUTO) < 0) |
