Closed
Bug 808121
Opened 12 years ago
Closed 12 years ago
Future Android system linker changes break Firefox linker
Categories
(Core :: mozglue, defect)
Tracking
()
RESOLVED
FIXED
mozilla19
People
(Reporter: glandium, Assigned: glandium)
Details
Attachments
(1 file, 1 obsolete file)
https://android-review.googlesource.com/#/c/45935/ This change essentially sets some linker internal structures read-only, which includes those we use to hook for gdb.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → mh+mozilla
Assignee | ||
Comment 1•12 years ago
|
||
Attachment #678094 -
Flags: review?(nfroyd)
Comment 2•12 years ago
|
||
Comment on attachment 678094 [details] [diff] [review] Ensure the pointers we change in the r_debug data are writable, which they aren't with upcoming Android system linker Review of attachment 678094 [details] [diff] [review]: ----------------------------------------------------------------- ::: mozglue/linker/ElfLoader.cpp @@ +591,5 @@ > + prot = getProt((uintptr_t) &ptr); > + /* Pointers are aligned such that their value can't be spanning across > + * 2 pages. */ > + page = (void*)((uintptr_t) &ptr & PAGE_MASK); > + if (!prot & PROT_WRITE) I am pretty sure that you want this to be !(prot & PROT_WRITE). @@ +597,5 @@ > + } > + > + ~EnsureWritable() > + { > + if (!prot & PROT_WRITE) Ditto. @@ +603,5 @@ > + } > + > +private: > + int getProt(uintptr_t addr) > + { This function was responsible for the grousing about lack of system calls to obtain protection bits, wasn't it? :) @@ +609,5 @@ > + * startAddr-endAddr rwxp */ > + int result = 0; > + char buf[1024]; > + FILE *f = fopen("/proc/self/maps", "r"); > + while (fgets(buf, sizeof(buf), f)) { FWIW, MapsMemoryReporter just uses fscanf here: http://mxr.mozilla.org/mozilla-central/source/xpcom/base/MapsMemoryReporter.cpp#305 Might be worth just using that instead, especially if you can figure out an easy way to just eat the rest of the line after the permission bits. @@ +614,5 @@ > + char *b = buf; > + uintptr_t startAddr, endAddr; > + startAddr = readAddr(b); > + if (*(b++) != '-') > + return -1; I approve of the attempt at error checking, but ISTM that if you're really going to try to do this, just returning -1 (effectively rwx) isn't the right way to approach it. Either propagate the error out further or just die early. @@ +674,5 @@ > * to adjust the l_prev value for the first element the system linker > * knows about. Fortunately, it doesn't use l_prev, and the first element > * is not ever going to be released before our elements, since it is the > * program executable, so the system linker should not be changing > * r_debug::r_map. Looks like this reference needs to be updated?
Attachment #678094 -
Flags: review?(nfroyd) → review-
Assignee | ||
Comment 3•12 years ago
|
||
Attachment #678649 -
Flags: review?(nfroyd)
Assignee | ||
Updated•12 years ago
|
Attachment #678094 -
Attachment is obsolete: true
Assignee | ||
Comment 4•12 years ago
|
||
(In reply to Nathan Froyd (:froydnj) from comment #2) > > * to adjust the l_prev value for the first element the system linker > > * knows about. Fortunately, it doesn't use l_prev, and the first element > > * is not ever going to be released before our elements, since it is the > > * program executable, so the system linker should not be changing > > * r_debug::r_map. > > Looks like this reference needs to be updated? Mmmm this hasn't changed.
Comment 5•12 years ago
|
||
Comment on attachment 678649 [details] [diff] [review] Ensure the pointers we change in the r_debug data are writable, which they aren't with upcoming Android system linker Review of attachment 678649 [details] [diff] [review]: ----------------------------------------------------------------- I like it. My comment about r_debug::r_map was mainly triggered by the methods that used to live in r_debug now living in DebuggerHelper, but leaving the comment still referring to r_debug. It wasn't immediately obvious to me that the reference was OK; I can certainly see why you left it that way.
Attachment #678649 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 6•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/e587aa26326e
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Comment 7•12 years ago
|
||
Comment on attachment 678649 [details] [diff] [review] Ensure the pointers we change in the r_debug data are writable, which they aren't with upcoming Android system linker Review of attachment 678649 [details] [diff] [review]: ----------------------------------------------------------------- ::: mozglue/linker/ElfLoader.cpp @@ +95,5 @@ > > int > __wrap_dl_iterate_phdr(dl_phdr_cb callback, void *data) > { > + if (ElfLoader::Singleton.dbg) Am I just confused or did this invert the meaning of the condition?
Assignee | ||
Comment 8•12 years ago
|
||
(In reply to :Ms2ger from comment #7) > > + if (ElfLoader::Singleton.dbg) > > Am I just confused or did this invert the meaning of the condition? Arg, you're right.
Assignee | ||
Comment 9•12 years ago
|
||
Thanks Ms2ger https://hg.mozilla.org/mozilla-central/rev/8776d96f0099
Comment 10•12 years ago
|
||
Np
You need to log in
before you can comment on or make changes to this bug.
Description
•