Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
d2b2b3f4
Commit
d2b2b3f4
authored
May 24, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6l, 8l: fix Mach-O binaries with many dynamic libraries
R=ken2 CC=golang-dev
https://golang.org/cl/4529084
parent
0b209b36
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
5 deletions
+24
-5
src/cmd/6l/obj.c
src/cmd/6l/obj.c
+1
-1
src/cmd/8l/obj.c
src/cmd/8l/obj.c
+1
-1
src/cmd/ld/macho.c
src/cmd/ld/macho.c
+21
-2
src/cmd/ld/macho.h
src/cmd/ld/macho.h
+1
-1
No files found.
src/cmd/6l/obj.c
View file @
d2b2b3f4
...
...
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
*/
tlsoffset
=
0x8a0
;
machoinit
();
HEADR
=
MACHORESERVE
;
HEADR
=
INITIAL_MACHO_HEADR
;
if
(
INITRND
==
-
1
)
INITRND
=
4096
;
if
(
INITTEXT
==
-
1
)
...
...
src/cmd/8l/obj.c
View file @
d2b2b3f4
...
...
@@ -218,7 +218,7 @@ main(int argc, char *argv[])
*/
tlsoffset
=
0x468
;
machoinit
();
HEADR
=
MACHORESERVE
;
HEADR
=
INITIAL_MACHO_HEADR
;
if
(
INITTEXT
==
-
1
)
INITTEXT
=
4096
+
HEADR
;
if
(
INITDAT
==
-
1
)
...
...
src/cmd/ld/macho.c
View file @
d2b2b3f4
...
...
@@ -17,6 +17,14 @@ static MachoSeg seg[16];
static
MachoDebug
xdebug
[
16
];
static
int
nload
,
mload
,
nseg
,
ndebug
,
nsect
;
// Amount of space left for adding load commands
// that refer to dynamic libraries. Because these have
// to go in the Mach-O header, we can't just pick a
// "big enough" header size. The initial header is
// one page, the non-dynamic library stuff takes
// up about 1300 bytes; we overestimate that as 2k.
static
int
load_budget
=
INITIAL_MACHO_HEADR
-
2
*
1024
;
void
machoinit
(
void
)
{
...
...
@@ -267,6 +275,17 @@ domacho(void)
void
machoadddynlib
(
char
*
lib
)
{
// Will need to store the library name rounded up
// and 24 bytes of header metadata. If not enough
// space, grab another page of initial space at the
// beginning of the output file.
load_budget
-=
(
strlen
(
lib
)
+
7
)
/
8
*
8
+
24
;
if
(
load_budget
<
0
)
{
HEADR
+=
4096
;
INITTEXT
+=
4096
;
load_budget
+=
4096
;
}
if
(
ndylib
%
32
==
0
)
{
dylib
=
realloc
(
dylib
,
(
ndylib
+
32
)
*
sizeof
dylib
[
0
]);
if
(
dylib
==
nil
)
{
...
...
@@ -463,8 +482,8 @@ asmbmacho(void)
}
a
=
machowrite
();
if
(
a
>
MACHORESERVE
)
diag
(
"
MACHORESERVE too small: %d > %d"
,
a
,
MACHORESERVE
);
if
(
a
>
HEADR
)
diag
(
"
HEADR too small: %d > %d"
,
a
,
HEADR
);
}
vlong
...
...
src/cmd/ld/macho.h
View file @
d2b2b3f4
...
...
@@ -63,7 +63,7 @@ void machoinit(void);
* for Header, PHeaders, and SHeaders.
* May waste some.
*/
#define
MACHORESERVE 3
*1024
#define
INITIAL_MACHO_HEADR 4
*1024
enum
{
MACHO_CPU_AMD64
=
(
1
<<
24
)
|
7
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment