annotate dyncallback/dyncall_thunk_sparc32.c @ 256:7520e2260097

- added to configure some detection on how to compile .s/.S with --noexecstack (or similar), as compilers' defaults are often insane - since no-execstack handling is now in build, remove .note.GNU-stack section markers (were of limites use, anyways, b/c unportable or implemented inconsistently across platforms) - some ToDo, etc. updates
author Tassilo Philipp
date Sat, 20 May 2017 00:02:59 +0200
parents b827c074b4da
children f5577f6bf97a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: dyncallback
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: dyncallback/dyncall_thunk_sparc32.c
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 Description: Thunk - Implementation for sparc32
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
9 Copyright (c) 2007-2016 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27 #include "dyncall_thunk.h"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 void dcbInitThunk(DCThunk* p, void (*entry)())
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 {
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
31 /* example
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
32 ; put thunk pointer in g1
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
33 0: 03 00 00 00 sethi %hi(0), %g1
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
34 4: 82 10 60 00 or %g1, 0, %g1
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
35 ; use g2 for entry pointer and "call" it, b/c branch instructions can't handle 32bit addresses
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
36 8: 05 00 00 00 sethi %hi(0), %g2
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
37 12: 84 10 a0 00 or %g2, 0, %g2
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
38 ; jump - write link to %g0, effectively discarding it; also nop for delay slot
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
39 16: 81 c0 80 00 jmpl %g2, %g0
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
40 20: 01 00 00 00 nop
189
b827c074b4da - first impl of sparc64 thunks
Tassilo Philipp
parents: 155
diff changeset
41 */
155
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
42
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
43 p->code[0] = 0x03000000 | ((unsigned int)p >> 10); /* sethi %hi(p), %g1 -- hi 22 bits */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
44 p->code[1] = 0x82106000 | ((unsigned int)p & 0x3ff); /* or %g1, <p&0x3ff>, %g1 -- lo 10 bits */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
45 p->code[2] = 0x05000000 | ((unsigned int)entry >> 10); /* sethi %hi(entry), %g2 */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
46 p->code[3] = 0x8410a000 | ((unsigned int)entry & 0x3ff); /* or %g2, <entry&0x3ff>, %g2 */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
47 p->code[4] = 0x81c08000; /* jmpl %g2, %g0 -- discards link addr */
bbefb8b8e74c - sparc32 thunk code
cslag
parents: 0
diff changeset
48 p->code[5] = 0x01000000; /* nop */
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50