Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7b65d1f authored by Frederick Mayle's avatar Frederick Mayle
Browse files

libbinder: support exporting fewer symbols

This commit explicitly marks symbols in the code with default visibility
if they should be part of the libbinder ABI. Later, we'll set the
default symbol visibility to hidden and so any symbols not explicitly
marked as exported will be hidden.

We are still overexporting symbols a bit. When `LIBBINDER_EXPORTED` is
applied to a class, it exports all of that class's symbols. I've tried
to only export class members, but in a few cases it didn't seem worth
the trouble, e.g. where all the members need to be exported.

Additionally, we are exporting some symbols only needed by binder test
binaries. Since those tests run against the standard libbinder.so, we
need to include the symbols as part of the ABI.

On aarch64, this reduces the size of libbinder_on_trusty_mock.so by
10.7% and libbinder.so by 7.5%, primarily in the .text, .dynstr, and
.dynsym sections (but none of this takes effect until we actually
enabled it in a later commit).

Bug: 338458975
Test: TH
Change-Id: Idc348c2b12124a8bbcebeea49920267a995367b6
parent 91f0294c
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
../../libs/binder/include/binder/Common.h
 No newline at end of file
+1 −2
Original line number Original line Diff line number Diff line
@@ -24,8 +24,7 @@
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
namespace android {
namespace android {


class BufferedTextOutput : public TextOutput
class LIBBINDER_INTERNAL_EXPORTED BufferedTextOutput : public TextOutput {
{
public:
public:
    //** Flags for constructor */
    //** Flags for constructor */
    enum {
    enum {
+4 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@
#include <sys/types.h>
#include <sys/types.h>
#include <string>
#include <string>


#include <binder/Common.h>

namespace android {
namespace android {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


@@ -35,7 +37,8 @@ void printHexData(int32_t indent, const void *buf, size_t length,
    size_t alignment=0, bool cArrayStyle=false,
    size_t alignment=0, bool cArrayStyle=false,
    debugPrintFunc func = nullptr, void* cookie = nullptr);
    debugPrintFunc func = nullptr, void* cookie = nullptr);


extern "C" ssize_t getBinderKernelReferences(size_t count, uintptr_t* buf);
// Used by libmemunreachable.
extern "C" LIBBINDER_EXPORTED ssize_t getBinderKernelReferences(size_t count, uintptr_t* buf);


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
} // namespace android
} // namespace android
+1 −1
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@
namespace android {
namespace android {


/** This is not a pipe. */
/** This is not a pipe. */
class FdTrigger {
class LIBBINDER_INTERNAL_EXPORTED FdTrigger {
public:
public:
    /** Returns nullptr for error case */
    /** Returns nullptr for error case */
    static std::unique_ptr<FdTrigger> make();
    static std::unique_ptr<FdTrigger> make();
+8 −6
Original line number Original line Diff line number Diff line
@@ -24,8 +24,8 @@


namespace android::binder::os {
namespace android::binder::os {


void trace_begin(uint64_t tag, const char* name);
LIBBINDER_EXPORTED void trace_begin(uint64_t tag, const char* name);
void trace_end(uint64_t tag);
LIBBINDER_EXPORTED void trace_end(uint64_t tag);


status_t setNonBlocking(borrowed_fd fd);
status_t setNonBlocking(borrowed_fd fd);


@@ -35,10 +35,12 @@ status_t dupFileDescriptor(int oldFd, int* newFd);


std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory();
std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory();


ssize_t sendMessageOnSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
LIBBINDER_INTERNAL_EXPORTED ssize_t
sendMessageOnSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
                    const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
                    const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);


ssize_t receiveMessageFromSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
LIBBINDER_INTERNAL_EXPORTED ssize_t
receiveMessageFromSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
                         std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
                         std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);


uint64_t GetThreadId();
uint64_t GetThreadId();
Loading